Commit 8ae052ff authored by Oleksandr Dmytrenko's avatar Oleksandr Dmytrenko

security provisioning cloud c++ fixs

security provisioning cloud c++ fixs

Change-Id: I56f5a67f8f471d935e69cec0527abd7a6a59f686
Signed-off-by: default avatarOleksandr Dmytrenko <o.dmytrenko@samsung.com>
parent 33afa843
......@@ -25,8 +25,8 @@
extern "C" {
#endif // __cplusplus
extern char *DEFAULT_QUERY;
extern char *DEFAULT_PREFIX;
extern const char *DEFAULT_QUERY;
extern const char *DEFAULT_PREFIX;
typedef OCStackResult (*UserFunctionCB)(void *params, void **data, OCClientResponse *clientResponse);
......
......@@ -44,6 +44,10 @@ static OCStackResult handleAclCreateGroupResponse(void *ctx, void **data,
OCClientResponse *response)
{
OC_UNUSED(ctx);
VERIFY_NON_NULL_RET(response, TAG, "NULL response", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(data, TAG, "NULL data", OC_STACK_INVALID_PARAM);
if (NULL == response->payload)
{
OIC_LOG(ERROR, TAG, "Receive NULL payload");
......@@ -74,6 +78,10 @@ static OCStackResult handleAclFindMyGroupResponse(void *ctx, void **data,
OCClientResponse *response)
{
OC_UNUSED(ctx);
VERIFY_NON_NULL_RET(response, TAG, "NULL response", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(data, TAG, "NULL data", OC_STACK_INVALID_PARAM);
if (NULL == response->payload)
{
OIC_LOG(ERROR, TAG, "Receive NULL payload");
......@@ -83,7 +91,7 @@ static OCStackResult handleAclFindMyGroupResponse(void *ctx, void **data,
const OCRepPayload *payload = (const OCRepPayload *)response->payload;
size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0 };
stringArray_t *gidlist = OICCalloc(1, sizeof(stringArray_t));
stringArray_t *gidlist = (stringArray_t *)OICCalloc(1, sizeof(stringArray_t));
if (NULL == gidlist)
{
OIC_LOG(ERROR, TAG, "Can't allocate gidlist");
......
......@@ -45,11 +45,10 @@
static OCStackResult getAclIdFromResponse(void *ctx, void **data, OCClientResponse *response)
{
OC_UNUSED(ctx);
if (NULL == response->payload)
{
OIC_LOG(ERROR, TAG, "Receive NULL payload");
return OC_STACK_INVALID_PARAM;
}
VERIFY_NON_NULL_RET(response, TAG, "NULL response", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(response->payload, TAG, "NULL payload response", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(data, TAG, "NULL data", OC_STACK_INVALID_PARAM);
char *aclid = NULL;
......@@ -102,8 +101,11 @@ OCStackResult OCCloudGetAclIdByDevice(void *ctx,
VERIFY_NON_NULL_RET(cloudUri, TAG, "NULL endpoint", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(deviceId, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
snprintf(uri, MAX_URI_LENGTH, "%s%s?%s=%s", cloudUri, OC_RSRVD_ACL_ID_URL, OC_RSRVD_DEVICE_ID,
deviceId);
if (MAX_URI_LENGTH - 1 <= snprintf(uri, MAX_URI_LENGTH, "%s%s?%s=%s",
cloudUri, OC_RSRVD_ACL_ID_URL, OC_RSRVD_DEVICE_ID, deviceId))
{
OIC_LOG_V(WARNING, TAG, "%s: uri truncated: %s", __func__, uri);
}
OCCallbackData cbData;
fillCallbackData(&cbData, ctx, callback, handleGetAclIdByDeviceResponse, NULL);
......@@ -124,9 +126,13 @@ OCStackResult OCCloudAclIdCreate(void *ctx,
VERIFY_NON_NULL_RET(ownerId, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(deviceId, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
snprintf(uri, MAX_URI_LENGTH, "%s%s?%s=%s&%s=%s",
cloudUri, OC_RSRVD_ACL_ID_URL,
OC_RSRVD_OWNER_ID, ownerId, OC_RSRVD_DEVICE_ID, deviceId);
if (MAX_URI_LENGTH - 1 <= snprintf(uri, MAX_URI_LENGTH, "%s%s?%s=%s&%s=%s",
cloudUri, OC_RSRVD_ACL_ID_URL,
OC_RSRVD_OWNER_ID, ownerId, OC_RSRVD_DEVICE_ID, deviceId))
{
OIC_LOG_V(WARNING, TAG, "%s: uri truncated: %s", __func__, uri);
}
OCCallbackData cbData;
fillCallbackData(&cbData, ctx, callback, handleAclIdCreateResponse, NULL);
......@@ -145,7 +151,12 @@ OCStackResult OCCloudAclIdDelete(void *ctx,
VERIFY_NON_NULL_RET(cloudUri, TAG, "NULL endpoint", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(aclId, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
snprintf(uri, MAX_URI_LENGTH, "%s%s?%s=%s", cloudUri, OC_RSRVD_ACL_ID_URL, OC_RSRVD_ACL_ID, aclId);
if (MAX_URI_LENGTH - 1 <= snprintf(uri, MAX_URI_LENGTH, "%s%s?%s=%s", cloudUri, OC_RSRVD_ACL_ID_URL,
OC_RSRVD_ACL_ID, aclId))
{
OIC_LOG_V(WARNING, TAG, "%s: uri truncated: %s", __func__, uri);
}
OCCallbackData cbData;
fillCallbackData(&cbData, ctx, callback, NULL, NULL);
......@@ -167,15 +178,13 @@ static OCStackResult handleAclGetInfoResponse(void *ctx, void **data, OCClientRe
OCStackResult result = OC_STACK_OK;
uint8_t *cbor = NULL;
size_t size = 0;
OicSecAcl_t *acl = NULL;
OC_UNUSED(ctx);
OC_UNUSED(data);
if (NULL == response->payload)
{
OIC_LOG(ERROR, TAG, "Receive NULL payload\n");
return OC_STACK_INVALID_PARAM;
}
VERIFY_NON_NULL_RET(response, TAG, "NULL response", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(response->payload, TAG, "NULL pyload response", OC_STACK_INVALID_PARAM);
result = OCConvertPayload(response->payload, OC_FORMAT_CBOR, &cbor, &size);
if (result != OC_STACK_OK)
......@@ -184,7 +193,7 @@ static OCStackResult handleAclGetInfoResponse(void *ctx, void **data, OCClientRe
goto exit;
}
OicSecAcl_t *acl = CBORPayloadToCloudAcl(cbor, size);
acl = CBORPayloadToCloudAcl(cbor, size);
if (NULL == acl)
{
OIC_LOG(ERROR, TAG, "Can't parse CBOR payload");
......@@ -213,16 +222,21 @@ exit:
}
OCStackResult OCCloudAclIndividualGetInfo(void *ctx,
const char *aclId,
const char *cloudUri,
OCCloudResponseCB callback)
const char *aclId,
const char *cloudUri,
OCCloudResponseCB callback)
{
char uri[MAX_URI_LENGTH] = { 0 };
VERIFY_NON_NULL_RET(cloudUri, TAG, "NULL endpoint", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(aclId, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
snprintf(uri, MAX_URI_LENGTH, "%s%s/%s", cloudUri, OC_RSRVD_ACL_ID_URL, aclId);
if (MAX_URI_LENGTH - 1 <= snprintf(uri, MAX_URI_LENGTH, "%s%s/%s", cloudUri, OC_RSRVD_ACL_ID_URL,
aclId))
{
OIC_LOG_V(WARNING, TAG, "%s: uri truncated: %s", __func__, uri);
}
OCCallbackData cbData;
fillCallbackData(&cbData, ctx, callback, handleAclGetInfoResponse, NULL);
......@@ -231,11 +245,44 @@ OCStackResult OCCloudAclIndividualGetInfo(void *ctx,
CT_ADAPTER_TCP, OC_LOW_QOS, &cbData, NULL, 0);
}
static bool aceValidate(cloudAce_t *aces)
{
cloudAce_t *ace = NULL;
size_t acllist_count = 0;
LL_FOREACH(aces, ace)
{
size_t reslist_count = 0;
OicSecRsrc_t *res = NULL;
LL_FOREACH( ace->resources, res)
{
if (NULL == res->href)
{
OIC_LOG_V(WARNING, TAG, "%s: wrong href of the resourse", __func__);
continue;
}
reslist_count++;
}
if(0 == reslist_count)
{
OIC_LOG_V(WARNING, TAG, "%s: there is no resourse", __func__);
return false;
}
acllist_count++;
}
if(0 == acllist_count)
{
OIC_LOG_V(WARNING, TAG, "%s: there is no acl", __func__);
return false;
}
return true;
}
OCStackResult OCCloudAclIndividualAclUpdate(void *ctx,
const char *aclId,
const cloudAce_t *aces,
const char *cloudUri,
OCCloudResponseCB callback)
const char *aclId,
const cloudAce_t *aces,
const char *cloudUri,
OCCloudResponseCB callback)
{
size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0 };
char uri[MAX_URI_LENGTH] = { 0 };
......@@ -244,12 +291,25 @@ OCStackResult OCCloudAclIndividualAclUpdate(void *ctx,
OCRepPayload **helperPayload = NULL;
OCRepPayload **helperPayload2 = NULL;
cloudAce_t *ace = NULL;
size_t acllist_count = 0;
VERIFY_NON_NULL_RET(cloudUri, TAG, "NULL endpoint", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(aclId, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(aces, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
snprintf(uri, MAX_URI_LENGTH, "%s%s/%s", cloudUri, OC_RSRVD_ACL_ID_URL, aclId);
if(!aceValidate((cloudAce_t*)aces))
{
OIC_LOG_V(WARNING, TAG, "%s: invalid aces", __func__);
return OC_STACK_INVALID_PARAM;
}
if (MAX_URI_LENGTH - 1 <= snprintf(uri, MAX_URI_LENGTH, "%s%s/%s", cloudUri, OC_RSRVD_ACL_ID_URL,
aclId))
{
OIC_LOG_V(WARNING, TAG, "%s: uri truncated: %s", __func__, uri);
}
OCRepPayload *payload = OCRepPayloadCreate();
if (!payload)
......@@ -258,7 +318,7 @@ OCStackResult OCCloudAclIndividualAclUpdate(void *ctx,
goto no_memory;
}
size_t acllist_count = 0;
acllist_count = 0;
//code below duplicates LL_COUNT, implemented in newer version of utlist.h
{
cloudAce_t *ace = (cloudAce_t *)aces;
......@@ -269,7 +329,7 @@ OCStackResult OCCloudAclIndividualAclUpdate(void *ctx,
}
}
helperPayload = OICCalloc(acllist_count, sizeof(OCRepPayload *));
helperPayload = (OCRepPayload **)OICCalloc(acllist_count, sizeof(OCRepPayload *));
if (!helperPayload)
{
OIC_LOG_V(DEBUG, TAG, "Can't allocate memory for helperPayload");
......@@ -277,8 +337,7 @@ OCStackResult OCCloudAclIndividualAclUpdate(void *ctx,
}
i = 0;
cloudAce_t *ace = NULL;
ace = NULL;
LL_FOREACH((cloudAce_t *)aces, ace)
{
OCRepPayload *acePayload = OCRepPayloadCreate();
......@@ -312,9 +371,10 @@ OCStackResult OCCloudAclIndividualAclUpdate(void *ctx,
}
}
helperPayload2 = OICCalloc(reslist_count, sizeof(OCRepPayload *));
helperPayload2 = (OCRepPayload **)OICCalloc(reslist_count, sizeof(OCRepPayload *));
if (!helperPayload2)
{
OIC_LOG_V(ERROR, TAG, "%s: Can't allocate memory", __func__);
goto no_memory;
}
......@@ -381,19 +441,32 @@ OCStackResult OCCloudAclIndividualAceUpdate(void *ctx,
{
size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0 };
char uri[MAX_URI_LENGTH] = { 0 };
cloudAce_t *ace;
int i = 0, j = 0;
OCRepPayload **helperPayload = NULL;
OCRepPayload **helperPayload2 = NULL;
size_t acllist_count;
VERIFY_NON_NULL_RET(cloudUri, TAG, "NULL endpoint", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(aclId, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(aceId, TAG, "NULL aceId", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(aces, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
snprintf(uri, MAX_URI_LENGTH, "%s%s/%s?%s=%s", cloudUri, OC_RSRVD_ACL_ID_URL, aclId,
OC_RSRVD_ACE_ID, aceId);
if(!aceValidate((cloudAce_t*)aces))
{
OIC_LOG_V(WARNING, TAG, "%s: invalid aces", __func__);
return OC_STACK_INVALID_PARAM;
}
if (MAX_URI_LENGTH - 1 <= snprintf(uri, MAX_URI_LENGTH, "%s%s/%s?%s=%s", cloudUri,
OC_RSRVD_ACL_ID_URL, aclId,
OC_RSRVD_ACE_ID, aceId))
{
OIC_LOG_V(WARNING, TAG, "%s: uri truncated: %s", __func__, uri);
}
OCRepPayload *payload = OCRepPayloadCreate();
if (!payload)
......@@ -402,9 +475,9 @@ OCStackResult OCCloudAclIndividualAceUpdate(void *ctx,
goto no_memory;
}
size_t acllist_count = 1;
acllist_count = 1;
helperPayload = OICCalloc(acllist_count, sizeof(OCRepPayload *));
helperPayload = (OCRepPayload **)OICCalloc(acllist_count, sizeof(OCRepPayload *));
if (!helperPayload)
{
OIC_LOG_V(DEBUG, TAG, "Can't allocate memory for helperPayload");
......@@ -412,7 +485,7 @@ OCStackResult OCCloudAclIndividualAceUpdate(void *ctx,
}
i = 0;
cloudAce_t *ace = NULL;
ace = NULL;
LL_FOREACH((cloudAce_t *)aces, ace)
{
......@@ -447,7 +520,7 @@ OCStackResult OCCloudAclIndividualAceUpdate(void *ctx,
}
}
helperPayload2 = OICCalloc(reslist_count, sizeof(OCRepPayload *));
helperPayload2 = (OCRepPayload **)OICCalloc(reslist_count, sizeof(OCRepPayload *));
if (!helperPayload2)
{
goto no_memory;
......@@ -519,7 +592,12 @@ OCStackResult OCCloudAclAcesDelete(void *ctx,
VERIFY_NON_NULL_RET(cloudUri, TAG, "NULL endpoint", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(aclId, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
snprintf(uri, MAX_URI_LENGTH, "%s%s/%s", cloudUri, OC_RSRVD_ACL_ID_URL, aclId);
if (MAX_URI_LENGTH - 1 <= snprintf(uri, MAX_URI_LENGTH, "%s%s/%s", cloudUri, OC_RSRVD_ACL_ID_URL,
aclId))
{
OIC_LOG_V(WARNING, TAG, "%s: uri truncated: %s", __func__, uri);
}
OCCallbackData cbData;
fillCallbackData(&cbData, ctx, callback, NULL, NULL);
......@@ -529,10 +607,10 @@ OCStackResult OCCloudAclAcesDelete(void *ctx,
}
OCStackResult OCCloudAclIndividualAceDelete(void *ctx,
const char *aclId,
const char *aceId,
const char *cloudUri,
OCCloudResponseCB callback)
const char *aclId,
const char *aceId,
const char *cloudUri,
OCCloudResponseCB callback)
{
char uri[MAX_URI_LENGTH] = { 0 };
......@@ -540,8 +618,13 @@ OCStackResult OCCloudAclIndividualAceDelete(void *ctx,
VERIFY_NON_NULL_RET(aclId, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(aceId, TAG, "NULL aceId", OC_STACK_INVALID_PARAM);
snprintf(uri, MAX_URI_LENGTH, "%s%s/%s?%s=%s", cloudUri, OC_RSRVD_ACL_ID_URL, aclId,
OC_RSRVD_ACE_ID, aceId);
if (MAX_URI_LENGTH - 1 <= snprintf(uri, MAX_URI_LENGTH, "%s%s/%s?%s=%s", cloudUri,
OC_RSRVD_ACL_ID_URL, aclId,
OC_RSRVD_ACE_ID, aceId))
{
OIC_LOG_V(WARNING, TAG, "%s: uri truncated: %s", __func__, uri);
}
OCCallbackData cbData;
fillCallbackData(&cbData, ctx, callback, NULL, NULL);
......
......@@ -48,6 +48,8 @@ static OCStackResult parseInvitePayload(const OCRepPayload *payload, const char
size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0 };
OCRepPayload **helperPayload = NULL;
size_t i = 0;
stringArray_t *gidlist = NULL;
stringArray_t *midlist = NULL;
if (!OCRepPayloadGetPropObjectArray(payload, name, &helperPayload, dimensions))
{
......@@ -56,21 +58,26 @@ static OCStackResult parseInvitePayload(const OCRepPayload *payload, const char
}
size_t count = calcDimTotal(dimensions);
if (0 == count)
{
OIC_LOG(ERROR, TAG, "zero list len");
goto exit;
}
stringArray_t *gidlist = &out->gidlist;
stringArray_t *midlist = &out->midlist;
gidlist = &out->gidlist;
midlist = &out->midlist;
gidlist->length = count;
midlist->length = count;
gidlist->array = OICCalloc(gidlist->length, sizeof(char *));
gidlist->array = (char**)OICCalloc(gidlist->length, sizeof(char *));
if (NULL == gidlist->array)
{
OIC_LOG(ERROR, TAG, "Can't allocate gidlist->array");
goto exit;
}
midlist->array = OICCalloc(midlist->length, sizeof(char *));
midlist->array = (char**)OICCalloc(midlist->length, sizeof(char *));
if (NULL == midlist->array)
{
OIC_LOG(ERROR, TAG, "Can't allocate midlist->array");
......@@ -83,14 +90,14 @@ static OCStackResult parseInvitePayload(const OCRepPayload *payload, const char
if (!OCRepPayloadGetPropString(gidPayload, OC_RSRVD_GROUP_ID, &gidlist->array[i]))
{
OIC_LOG_V(ERROR, TAG, "Can't get: %s", OC_RSRVD_GROUP_ID);
OIC_LOG_V(ERROR, TAG, "Can't get group id: %s", OC_RSRVD_GROUP_ID);
result = OC_STACK_MALFORMED_RESPONSE;
goto exit;
}
if (!OCRepPayloadGetPropString(gidPayload, OC_RSRVD_MEMBER_ID, &midlist->array[i]))
{
OIC_LOG_V(ERROR, TAG, "Can't get: %s", OC_RSRVD_MEMBER_ID);
OIC_LOG_V(ERROR, TAG, "Can't get member id: %s", OC_RSRVD_MEMBER_ID);
result = OC_STACK_MALFORMED_RESPONSE;
goto exit;
}
......@@ -128,13 +135,16 @@ static OCStackResult handleAclGetInvitationResponse(void *ctx, void **data,
OC_UNUSED(ctx);
OCStackResult result = OC_STACK_OK;
VERIFY_NON_NULL_RET(response, TAG, "NULL response", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(data, TAG, "NULL data", OC_STACK_INVALID_PARAM);
if (NULL == response->payload)
{
OIC_LOG(ERROR, TAG, "Receive NULL payload");
return OC_STACK_INVALID_PARAM;
}
inviteResponse_t *answer = OICCalloc(1, sizeof(inviteResponse_t));
inviteResponse_t *answer = (inviteResponse_t*)OICCalloc(1, sizeof(inviteResponse_t));
if (NULL == answer)
{
OIC_LOG(ERROR, TAG, "Can't allocate answer");
......@@ -173,6 +183,9 @@ static OCStackResult handleAclPolicyCheckResponse(void *ctx, void **data,
{
OC_UNUSED(ctx);
VERIFY_NON_NULL_RET(response, TAG, "NULL response", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(data, TAG, "NULL data", OC_STACK_INVALID_PARAM);
if (NULL == response->payload)
{
OIC_LOG(ERROR, TAG, "Receive NULL payload");
......@@ -202,11 +215,18 @@ OCStackResult OCCloudAclInviteUser(void *ctx,
OCStackResult result = OC_STACK_ERROR;
char uri[MAX_URI_LENGTH] = { 0 };
size_t i = 0;
size_t dimensions[MAX_REP_ARRAY_DEPTH] = {0, 0, 0};
VERIFY_NON_NULL_RET(cloudUri, TAG, "NULL endpoint", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(groupIds, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL_RET(memberIds, TAG, "NULL input param", OC_STACK_INVALID_PARAM);
if (0 == groupIds->length)
{
OIC_LOG(ERROR, TAG, "groups length is 0");
return OC_STACK_INVALID_PARAM;
}
if (groupIds->length != memberIds->length)
{
OIC_LOG(ERROR, TAG, "members and groups lists should have the same length!!!");
......@@ -225,7 +245,7 @@ OCStackResult OCCloudAclInviteUser(void *ctx,
return OC_STACK_NO_MEMORY;
}
OCRepPayload **heplerPayload = OICCalloc(groupIds->length, sizeof(OCRepPayload *));
OCRepPayload **heplerPayload = (OCRepPayload**)OICCalloc(groupIds->length, sizeof(OCRepPayload *));
if (NULL == heplerPayload)
{
OCRepPayloadDestroy(payload);
......@@ -246,7 +266,6 @@ OCStackResult OCCloudAclInviteUser(void *ctx,
//add next fields if they were filled
if (userId) OCRepPayloadSetPropString(payload, OC_RSRVD_USER_UUID, userId);
size_t dimensions[MAX_REP_ARRAY_DEPTH] = {0, 0, 0};
dimensions[0] = groupIds->length;
OCRepPayloadSetPropObjectArray(payload, OC_RSRVD_INVITE,
(const struct OCRepPayload **)heplerPayload, dimensions);
......
......@@ -51,6 +51,8 @@ static OCStackResult handleCrlGetResponse(void *ctx, void **data, OCClientRespon
OC_UNUSED(ctx);
OC_UNUSED(data);
VERIFY_NON_NULL_RET(response, TAG, "NULL response", OC_STACK_INVALID_PARAM);
if (NULL == response->payload)
{
OIC_LOG(ERROR, TAG, "Receive NULL payload\n");
......@@ -164,7 +166,7 @@ OCStackResult OCCloudPostCRL(void *ctx,
OIC_LOG(DEBUG, TAG, "Next payload created:");
OIC_LOG_PAYLOAD(DEBUG, (OCPayload *)payload);
secPayload = OICCalloc(1, sizeof(OCSecurityPayload));
secPayload = (OCSecurityPayload*)OICCalloc(1, sizeof(OCSecurityPayload));
if (!secPayload)
{
OIC_LOG(ERROR, TAG, "Can't allocate secPayload");
......
......@@ -383,6 +383,8 @@ OCStackResult OCCloudCertificateIssueRequest(void *ctx,
OCCloudResponseCB callback)
{
OCStackResult ret = OC_STACK_OK;
char uri[MAX_URI_QUERY] = { 0 };
OCRepPayload *payload = NULL;
OIC_LOG_V(DEBUG, TAG, "IN: %s", __func__);
......@@ -399,7 +401,7 @@ OCStackResult OCCloudCertificateIssueRequest(void *ctx,
OIC_LOG_V(DEBUG, TAG, "Certificate Request subject: %s", subject);
OCByteString request = { 0 };
OCByteString request = { NULL, 0 };
if (0 != GenerateCSR(subject, &request))
{
OIC_LOG(ERROR, TAG, "Cann't get the sertificate request");
......@@ -412,7 +414,7 @@ OCStackResult OCCloudCertificateIssueRequest(void *ctx,
OIC_LOG(DEBUG, TAG, "Private Key:");
OIC_LOG_BUFFER(DEBUG, TAG, g_privateKey.bytes, g_privateKey.len);
OCRepPayload *payload = OCRepPayloadCreate();
payload = OCRepPayloadCreate();
if (!payload)
{
OIC_LOG(ERROR, TAG, "Failed to memory allocation");
......@@ -432,7 +434,6 @@ OCStackResult OCCloudCertificateIssueRequest(void *ctx,
OIC_LOG_PAYLOAD(DEBUG, (OCPayload *)payload);
char uri[MAX_URI_QUERY] = { 0 };
snprintf(uri, MAX_URI_QUERY, "%s%s", cloudUri, OC_RSRVD_PROV_CERT_URI);
OIC_LOG_V(DEBUG, TAG, "Certificate Request Query: %s", uri);
......
......@@ -35,8 +35,8 @@ typedef struct {
void *params;
}ContextInfo_t;
char *DEFAULT_QUERY = COAP_TCP_QUERY;
char *DEFAULT_PREFIX = COAP_TCP_PREFIX;
const char *DEFAULT_QUERY = COAP_TCP_QUERY;
const char *DEFAULT_PREFIX = COAP_TCP_PREFIX;
/**
* This function sets required CoAP prefix depending on
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment