}
size_t len = strlen(rsrc_in)+1; // '1' for null termination
rsrc->href = (char*) OICCalloc(len, sizeof(char));
- if(!rsrc)
+ if(!rsrc->href)
{
OIC_LOG(ERROR, TAG, "createAcl: OICCalloc error return");
goto CRACL_ERROR;
}
OICStrcpy(rsrc->href, len, rsrc_in);
- int arrLen = 0;
+ size_t arrLen = 0;
while(1)
{
printf(" Enter Number of resource type for [%s] : ", rsrc->href);
for( ; 0x20<=getchar(); ); // for removing overflow garbages
// '0x20<=code' is character region
}
- if(0 < arrLen && ACL_RESRC_ARRAY_SIZE >= arrLen)
+ if(ACL_RESRC_ARRAY_SIZE >= arrLen)
{
break;
}
for( ; 0x20<=getchar(); ); // for removing overflow garbages
// '0x20<=code' is character region
}
- if(0 < arrLen && ACL_RESRC_ARRAY_SIZE >= arrLen)
+ if(ACL_RESRC_ARRAY_SIZE >= arrLen)
{
break;
}
OCStackResult res = OC_STACK_ERROR;
OCProvisionDev_t* pTargetDev = NULL;
bool discoverdFlag = false;
+ OCProvisionDev_t* pOwnedDevList = NULL;
if (!pTargetUuid || 0 == waitTimeForOwnedDeviceDiscovery)
{
goto error;
}
- OCProvisionDev_t* pOwnedDevList = NULL;
//2. Find owned device from the network
res = PMDeviceDiscovery(waitTimeForOwnedDeviceDiscovery, true, &pOwnedDevList);
if (OC_STACK_OK != res)
goto error;
}
OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
-
- OCProvisionDev_t * targetDev = PMCloneOCProvisionDev(pTargetDev);
+
OCCallbackData cbData = { .context = NULL, .cb = NULL, .cd = NULL };
+ OCMethod method = OC_REST_POST;
+ OCDoHandle handle = NULL;
+ OCProvisionDev_t * targetDev = PMCloneOCProvisionDev(pTargetDev);
+ if (NULL == targetDev)
+ {
+ OIC_LOG(ERROR, TAG, "target dev is null");
+ res = OC_STACK_ERROR;
+ goto error;
+ }
cbData.cb = &SRPResetDeviceCB;
cbData.context = (void *) targetDev;
cbData.cd = NULL;
- OCMethod method = OC_REST_POST;
- OCDoHandle handle = NULL;
OIC_LOG(DEBUG, TAG, "Sending PSTAT info to resource server");
res = OCDoResource(&handle, method, query,
&targetDev->endpoint, (OCPayload *)secPayload,
dev2 = tempDev;
break;
}
- else
- {
- break;
- }
}
tempDev = tempDev->next;
}
return;
}
uint32_t outSize;
- b64Decode(temp->optionalData.data, temp->optionalData.len, buf, bufSize, &outSize);
+ if(B64_OK != b64Decode(temp->optionalData.data, temp->optionalData.len, buf, bufSize, &outSize))
+ {
+ OICFree(buf);
+ OIC_LOG(ERROR, TAG, "Failed to decode base64 data");
+ return;
+ }
crt->data = OICRealloc(crt->data, crt->len + outSize);
memcpy(crt->data + crt->len, buf, outSize);
crt->len += outSize;
for(size_t i = 0; i < rsrc->typeLen; i++)
{
cJSON *jsonRsrcType = cJSON_GetArrayItem(jsonRsrcObj, i);
+ VERIFY_NON_NULL(TAG, jsonRsrcType, ERROR);
rsrc->types[i] = OICStrdup(jsonRsrcType->valuestring);
VERIFY_NON_NULL(TAG, (rsrc->types[i]), ERROR);
}
for(size_t i = 0; i < rsrc->interfaceLen; i++)
{
cJSON *jsonInterface = cJSON_GetArrayItem(jsonRsrcObj, i);
+ VERIFY_NON_NULL(TAG, jsonInterface, ERROR);
rsrc->interfaces[i] = OICStrdup(jsonInterface->valuestring);
VERIFY_NON_NULL(TAG, (rsrc->interfaces[i]), ERROR);
}
if(jsonValidityObj)
{
VERIFY_SUCCESS(TAG, cJSON_Array == jsonValidityObj->type, ERROR);
- size_t validityLen = cJSON_GetArraySize(jsonValidityObj);
+ size_t validityLen = (size_t) cJSON_GetArraySize(jsonValidityObj);
VERIFY_SUCCESS(TAG, (0 < validityLen), ERROR);
cJSON *jsonValidity = NULL;
if(jsonRecurObj)
{
VERIFY_SUCCESS(TAG, (cJSON_Array == jsonRecurObj->type), ERROR);
- validity->recurrenceLen = cJSON_GetArraySize(jsonRecurObj);
+ validity->recurrenceLen = (size_t) cJSON_GetArraySize(jsonRecurObj);
VERIFY_SUCCESS(TAG, (0 < validity->recurrenceLen), ERROR);
validity->recurrences = (char**)OICCalloc(validity->recurrenceLen, sizeof(char*));
OICFree(temp_rsc);
char* rsrc_in = NULL;
- int arrLen = 0;
+ size_t arrLen = 0;
while(1)
{
printf(" Enter Number of resource type for [%s]: ", rsrc->href);
for( ; 0x20<=getchar(); ); // for removing overflow garbages
// '0x20<=code' is character region
}
- if(0 < arrLen && ACL_RESRC_ARRAY_SIZE >= arrLen)
+ if(ACL_RESRC_ARRAY_SIZE >= arrLen)
{
break;
}
for( ; 0x20<=getchar(); ); // for removing overflow garbages
// '0x20<=code' is character region
}
- if(0 < arrLen && ACL_RESRC_ARRAY_SIZE >= arrLen)
+ if(ACL_RESRC_ARRAY_SIZE >= arrLen)
{
break;
}
}
rewind(fp);
fsize = fread(trustCertChainArray.data, 1, fsize, fp);
+ if(0 == fsize)
+ {
+ OIC_LOG(ERROR,TAG,"Read error");
+ }
fclose(fp);
}
}