return outpdu;
exit:
+ OIC_LOG(DEBUG, TAG, "data :");
+ OIC_LOG_BUFFER(DEBUG, TAG, (const uint8_t*) data, length);
coap_delete_pdu(outpdu);
return NULL;
}
{
unsigned char uriBuffer[CA_MAX_URI_LENGTH] = { 0 };
unsigned char *pBuf = uriBuffer;
- size_t buflen = sizeof(uriBuffer);
- int res = (target == COAP_OPTION_URI_PATH) ? coap_split_path(str, length, pBuf, &buflen) :
- coap_split_query(str, length, pBuf, &buflen);
+ size_t unusedBufferSize = sizeof(uriBuffer);
+ int res = (target == COAP_OPTION_URI_PATH) ? coap_split_path(str, length, pBuf, &unusedBufferSize) :
+ coap_split_query(str, length, pBuf, &unusedBufferSize);
if (res > 0)
{
+ assert(unusedBufferSize < sizeof(uriBuffer));
+ size_t usedBufferSize = sizeof(uriBuffer) - unusedBufferSize;
size_t prevIdx = 0;
while (res--)
{
}
size_t optSize = COAP_OPT_SIZE(pBuf);
- if ((prevIdx + optSize) < buflen)
+ if (prevIdx + optSize > usedBufferSize)
{
- pBuf += optSize;
- prevIdx += optSize;
+ assert(false);
+ return CA_STATUS_INVALID_PARAM;
}
+ pBuf += optSize;
+ prevIdx += optSize;
}
}
else
}
else
{
- OIC_LOG_V(DEBUG, TAG, "Head opt ID: %d", id);
- OIC_LOG_V(DEBUG, TAG, "Head opt data: %s", (info->options + i)->optionData);
- OIC_LOG_V(DEBUG, TAG, "Head opt length: %d", (info->options + i)->optionLength);
+ OIC_LOG_V(DEBUG, TAG, "Head opt ID[%d], length[%d]", id, (info->options + i)->optionLength);
int ret = coap_insert(optlist,
CACreateNewOptionNode(id, (info->options + i)->optionLength,
(info->options + i)->optionData),
coap_get_token2(pdu_hdr, transport, &token, &token_length);
// set token data
- if (token_length > 0)
+ if (token && token_length > 0)
{
OIC_LOG_V(DEBUG, TAG, "token len:%d", token_length);
outInfo->token = (char *) OICMalloc(token_length);
{
return true;
}
+ OIC_LOG_V(DEBUG, TAG, "adapter value of BWT is %d", adapter);
return false;
}
#endif
{
return true;
}
+ OIC_LOG_V(DEBUG, TAG, "adapter value of CoAP/TCP is %d", adapter);
return false;
}
#endif