if (result == BT_ERROR_NONE && NULL != man_data)
{
- char *compare_man_data = OICCalloc(1, (man_data_len*2)+1);
int pos =0;
+ char *compare_man_data = OICCalloc(1, (man_data_len*2)+1);
+ if (!compare_man_data)
+ {
+ OIC_LOG(ERROR, CALEADAPTER_TAG, "Memory allocation failed for compare_man_data");
+ OICFree(man_data);
+ return false;
+ }
+
for(int i=0;i<man_data_len;i++){
- pos += sprintf(compare_man_data+pos, "%.2x", man_data[i]);
+ pos += snprintf(compare_man_data+pos, 2, "%.2x", man_data[i]);
}
if (man_id == samsung_code && 0 == strncasecmp(compare_man_data, service_uuid, CUSTOM_UUID_LEN))
for (size_t i = 0; i < len; i++)
{
CABlockData_t *blockData = (CABlockData_t *) u_arraylist_get(g_context.dataList, i);
- if (CABlockidMatches(blockData, blockID))
+ if (blockData && CABlockidMatches(blockData, blockID))
{
uint64_t now = OICGetCurrentTime(TIME_IN_US);
blockData->ttl = now + (BLOCK_DATA_TIMEOUT_SECONDS * USECS_PER_SEC);
if(cloud_address && *cloud_address)
{
char message[4096];
- int len = sprintf(message,
+ int len = snprintf(message, 4096,
"CONNECT %s HTTP/1.1\r\n"
"Host: %s\r\n\r\n", cloud_address, cloud_address
);
actionTypeStr = (char *)OICMalloc(1024);
if(actionTypeStr != NULL)
{
- sprintf(actionTypeStr, "%ld %u", actionset->timesteps, actionset->type);
+ snprintf(actionTypeStr, 1024, "%ld %u", actionset->timesteps, actionset->type);
if(remaining >= strlen(actionTypeStr) + strlen(ACTION_DELIMITER) + 1)
{
strncat(temp, actionTypeStr, strlen(actionTypeStr));
goto exit;
}
- strcat(temp, "uri=");
+ strncat(temp, "uri=", 4);
remaining -= strlen("uri=");
- strcat(temp, action->resourceUri);
+ strncat(temp, action->resourceUri, strlen(action->resourceUri));
remaining -= strlen(action->resourceUri);
- strcat(temp, "|");
+ strncat(temp, "|", 1);
remaining--;
OCCapability *capas = action->head;
}
jsonStr = cJSON_PrintUnformatted(json);
+ if (jsonStr == NULL)
+ {
+ OIC_LOG(ERROR, TAG, "cJSON_PrintUnformatted failed");
+ cJSON_Delete(json);
+ return OC_STACK_ERROR;
+ }
jsonLen = strlen(jsonStr);
if (jsonLen < *remaining)