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

  1. From f182119e571a1b520b4e5ef4ee5e5b5cd243b931 Mon Sep 17 00:00:00 2001
  2. From: Chul Lee <chuls.lee@samsung.com>
  3. Date: Wed, 22 Jun 2016 12:40:21 +0900
  4. Subject: [PATCH] Remove the endianness dependency in cbor conversion.
  5. A similar bug reported from https://gerrit.iotivity.org/gerrit/#/c/8755/
  6. Change-Id: I631bab77f7486f1f45eaff96c67d39606e37c6b6
  7. Signed-off-by: Chul Lee <chuls.lee@samsung.com>
  8. Reviewed-on: https://gerrit.iotivity.org/gerrit/8829
  9. Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
  10. Reviewed-by: Hauke Mehrtens <hauke.mehrtens@intel.com>
  11. Reviewed-by: Randeep Singh <randeep.s@samsung.com>
  12. (cherry picked from commit 24474a8d2555229efb425b6cb63e19b3279ba810)
  13. Reviewed-on: https://gerrit.iotivity.org/gerrit/9053
  14. ---
  15. resource/csdk/security/src/credresource.c | 8 ++++++--
  16. resource/csdk/security/src/pconfresource.c | 5 +++--
  17. resource/csdk/stack/src/ocpayloadparse.c | 8 ++++++--
  18. 3 files changed, 15 insertions(+), 6 deletions(-)
  19. --- a/resource/csdk/security/src/credresource.c
  20. +++ b/resource/csdk/security/src/credresource.c
  21. @@ -435,8 +435,10 @@ OCStackResult CBORPayloadToCred(const ui
  22. //credid
  23. if (strcmp(name, OIC_JSON_CREDID_NAME) == 0)
  24. {
  25. - cborFindResult = cbor_value_get_uint64(&credMap, (uint64_t *) &cred->credId);
  26. + uint64_t credId = 0;
  27. + cborFindResult = cbor_value_get_uint64(&credMap, &credId);
  28. VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding CredId.");
  29. + cred->credId = (uint16_t)credId;
  30. }
  31. // subjectid
  32. if (strcmp(name, OIC_JSON_SUBJECTID_NAME) == 0)
  33. @@ -451,8 +453,10 @@ OCStackResult CBORPayloadToCred(const ui
  34. // credtype
  35. if (strcmp(name, OIC_JSON_CREDTYPE_NAME) == 0)
  36. {
  37. - cborFindResult = cbor_value_get_uint64(&credMap, (uint64_t *) &cred->credType);
  38. + uint64_t credType = 0;
  39. + cborFindResult = cbor_value_get_uint64(&credMap, &credType);
  40. VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding CredType.");
  41. + cred->credType = (OicSecCredType_t)credType;
  42. }
  43. // privatedata
  44. if (strcmp(name, OIC_JSON_PRIVATEDATA_NAME) == 0)
  45. --- a/resource/csdk/security/src/pconfresource.c
  46. +++ b/resource/csdk/security/src/pconfresource.c
  47. @@ -642,8 +642,9 @@ OCStackResult CBORPayloadToPconf(const u
  48. // Permissions -- Mandatory
  49. if (strcmp(name, OIC_JSON_PERMISSION_NAME) == 0)
  50. {
  51. - cborFindResult = cbor_value_get_uint64(&pdAclMap,
  52. - (uint64_t *) &pdacl->permission);
  53. + uint64_t permission = 0;
  54. + cborFindResult = cbor_value_get_uint64(&pdAclMap, &permission);
  55. + pdacl->permission = (uint16_t)permission;
  56. VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get value");
  57. }
  58. --- a/resource/csdk/stack/src/ocpayloadparse.c
  59. +++ b/resource/csdk/stack/src/ocpayloadparse.c
  60. @@ -1169,17 +1169,21 @@ static OCStackResult OCParsePresencePayl
  61. if (cbor_value_is_map(rootValue))
  62. {
  63. CborValue curVal;
  64. + uint64_t temp = 0;
  65. // Sequence Number
  66. CborError err = cbor_value_map_find_value(rootValue, OC_RSRVD_NONCE, &curVal);
  67. VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding nonce tag");
  68. - err = cbor_value_get_uint64(&curVal, (uint64_t *)&payload->sequenceNumber);
  69. + err = cbor_value_get_uint64(&curVal, &temp);
  70. + payload->sequenceNumber = (uint32_t)temp;
  71. VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding nonce value");
  72. // Max Age
  73. err = cbor_value_map_find_value(rootValue, OC_RSRVD_TTL, &curVal);
  74. VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding ttl tag");
  75. - err = cbor_value_get_uint64(&curVal, (uint64_t *)&payload->maxAge);
  76. + temp = 0;
  77. + err = cbor_value_get_uint64(&curVal, &temp);
  78. + payload->maxAge = (uint32_t)temp;
  79. VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding ttl value");
  80. // Trigger