Fix TEE_GetPropertyName 06/171106/4
authorKrzysztof Dynowski <k.dynowski@samsung.com>
Mon, 26 Feb 2018 11:05:04 +0000 (12:05 +0100)
committerKrzysztof Dynowski <k.dynowski@samsung.com>
Tue, 27 Feb 2018 13:29:23 +0000 (14:29 +0100)
Change-Id: I9e6695059b312124cb25cf96e6e7ee731dbf3759

TEEStub/PropertyAccess/PropertyApi.cpp

index 323e489..dfe8210 100644 (file)
@@ -374,25 +374,18 @@ void TEE_ResetPropertyEnumerator(TEE_PropSetHandle enumerator) {
  */\r
 TEE_Result TEE_GetPropertyName(TEE_PropSetHandle enumerator, void* nameBuffer,\r
     size_t* nameBufferLen) {\r
-       Property* targetProperty = NULL;\r
-       // 1. Select the enumerator object based on propset or consider given enumerator\r
-       // if any\r
-       targetProperty = _GetTargetProperty(enumerator);\r
-       PropertyEnumHandle* enumeratorHandle = (PropertyEnumHandle*)enumerator;\r
-       // Check if enumerator and property are valid\r
-       //if (enumeratorHandle && enumeratorHandle->property) {\r
-       if (enumeratorHandle && targetProperty) {\r
-               string propName;\r
-               // If item exists and and not reached end of enumerator, get the name\r
-               if (enumeratorHandle->property->getPropertyName(propName)) {\r
-                       if (*nameBufferLen < propName.size() + 1) return TEE_ERROR_SHORT_BUFFER;\r
-                       strncpy((char*)nameBuffer, propName.c_str(), *nameBufferLen);\r
-               }\r
-               // item not found or enumerator end has reached\r
-               else return TEE_ERROR_ITEM_NOT_FOUND;\r
-       }\r
-       else return TEE_ERROR_ITEM_NOT_FOUND;\r
-       return TEE_SUCCESS;\r
+       Property* targetProperty = _GetTargetProperty(enumerator);
+       if (targetProperty != NULL) {
+               string propName;
+               if (targetProperty->getPropertyName(propName)) {
+                       if (*nameBufferLen < propName.size() + 1) {
+                               return TEE_ERROR_SHORT_BUFFER;
+                       }
+                       strncpy((char*)nameBuffer, propName.c_str(), propName.size() + 1);
+                       return TEE_SUCCESS;
+               }
+       }
+       return TEE_ERROR_ITEM_NOT_FOUND;
 }\r
 \r
 TEE_Result TEE_GetNextProperty(TEE_PropSetHandle enumerator) {\r