You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

87 lines
4.5 KiB

From f182119e571a1b520b4e5ef4ee5e5b5cd243b931 Mon Sep 17 00:00:00 2001
From: Chul Lee <chuls.lee@samsung.com>
Date: Wed, 22 Jun 2016 12:40:21 +0900
Subject: [PATCH] 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: Chul Lee <chuls.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/8829
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Hauke Mehrtens <hauke.mehrtens@intel.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
(cherry picked from commit 24474a8d2555229efb425b6cb63e19b3279ba810)
Reviewed-on: https://gerrit.iotivity.org/gerrit/9053
---
resource/csdk/security/src/credresource.c | 8 ++++++--
resource/csdk/security/src/pconfresource.c | 5 +++--
resource/csdk/stack/src/ocpayloadparse.c | 8 ++++++--
3 files changed, 15 insertions(+), 6 deletions(-)
--- a/resource/csdk/security/src/credresource.c
+++ b/resource/csdk/security/src/credresource.c
@@ -435,8 +435,10 @@ OCStackResult CBORPayloadToCred(const ui
//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)
@@ -451,8 +453,10 @@ OCStackResult CBORPayloadToCred(const ui
// 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)
--- a/resource/csdk/security/src/pconfresource.c
+++ b/resource/csdk/security/src/pconfresource.c
@@ -642,8 +642,9 @@ OCStackResult CBORPayloadToPconf(const u
// Permissions -- Mandatory
if (strcmp(name, OIC_JSON_PERMISSION_NAME) == 0)
{
- 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");
}
--- a/resource/csdk/stack/src/ocpayloadparse.c
+++ b/resource/csdk/stack/src/ocpayloadparse.c
@@ -1169,17 +1169,21 @@ static OCStackResult OCParsePresencePayl
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