Commit 24474a8d authored by Chul Lee's avatar Chul Lee Committed by Randeep

Remove the endianness dependency in cbor conversion.

A similar bug reported from https://gerrit.iotivity.org/gerrit/#/c/8755/

Change-Id: I631bab77f7486f1f45eaff96c67d39606e37c6b6
Signed-off-by: default avatarChul Lee <chuls.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/8829Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarHauke Mehrtens <hauke.mehrtens@intel.com>
Reviewed-by: Randeep's avatarRandeep Singh <randeep.s@samsung.com>
parent 153cb264
......@@ -460,8 +460,10 @@ OCStackResult CBORPayloadToCred(const uint8_t *cborPayload, size_t size,
//credid
if (strcmp(name, OIC_JSON_CREDID_NAME) == 0)
{
cborFindResult = cbor_value_get_uint64(&credMap, (uint64_t *) &cred->credId);
uint64_t credId = 0;
cborFindResult = cbor_value_get_uint64(&credMap, &credId);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding CredId.");
cred->credId = (uint16_t)credId;
}
// subjectid
if (strcmp(name, OIC_JSON_SUBJECTID_NAME) == 0)
......@@ -476,8 +478,10 @@ OCStackResult CBORPayloadToCred(const uint8_t *cborPayload, size_t size,
// credtype
if (strcmp(name, OIC_JSON_CREDTYPE_NAME) == 0)
{
cborFindResult = cbor_value_get_uint64(&credMap, (uint64_t *) &cred->credType);
uint64_t credType = 0;
cborFindResult = cbor_value_get_uint64(&credMap, &credType);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding CredType.");
cred->credType = (OicSecCredType_t)credType;
}
// privatedata
if (strcmp(name, OIC_JSON_PRIVATEDATA_NAME) == 0)
......
......@@ -642,8 +642,9 @@ OCStackResult CBORPayloadToPconf(const uint8_t *cborPayload, size_t size, OicSec
// Permissions -- Mandatory
if (strcmp(name, OIC_JSON_PERMISSION_NAME) == 0 && cbor_value_is_unsigned_integer(&pdAclMap))
{
cborFindResult = cbor_value_get_uint64(&pdAclMap,
(uint64_t *) &pdacl->permission);
uint64_t permission = 0;
cborFindResult = cbor_value_get_uint64(&pdAclMap, &permission);
pdacl->permission = (uint16_t)permission;
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get value");
}
......
......@@ -1190,17 +1190,21 @@ static OCStackResult OCParsePresencePayload(OCPayload **outPayload, CborValue *r
if (cbor_value_is_map(rootValue))
{
CborValue curVal;
uint64_t temp = 0;
// Sequence Number
CborError err = cbor_value_map_find_value(rootValue, OC_RSRVD_NONCE, &curVal);
VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding nonce tag");
err = cbor_value_get_uint64(&curVal, (uint64_t *)&payload->sequenceNumber);
err = cbor_value_get_uint64(&curVal, &temp);
payload->sequenceNumber = (uint32_t)temp;
VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding nonce value");
// Max Age
err = cbor_value_map_find_value(rootValue, OC_RSRVD_TTL, &curVal);
VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding ttl tag");
err = cbor_value_get_uint64(&curVal, (uint64_t *)&payload->maxAge);
temp = 0;
err = cbor_value_get_uint64(&curVal, &temp);
payload->maxAge = (uint32_t)temp;
VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding ttl value");
// Trigger
......
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