security: fix reading of permission attribute from configuration
authorHauke Mehrtens <hauke.mehrtens@intel.com>
Fri, 17 Jun 2016 15:38:35 +0000 (17:38 +0200)
committerRandeep Singh <randeep.s@samsung.com>
Tue, 21 Jun 2016 05:16:30 +0000 (05:16 +0000)
Casting the pointer to the permission attribute from uint16_t to uint64_t
causes problems on MIPS Big Endian systems and probably othrs as well.
When the calling method interprets it as uint64_t not the value is
converted but the pointer is interpreted as it would point to a 64 bit
integer, but it is only a 16 bit wide integer. On MIPS BE permission was
always 0 independent of which value between 0 and 32 the permission
attribute had, this was probably written to some padding area or into
some other member of the struct.

This patch fixes the memory corruption and makes the code work for me with
a MIPS BE CPU.

Change-Id: Ifa843e69980ad4309b1e3076b8e2c98c03324352
Signed-off-by: Hauke Mehrtens <hauke.mehrtens@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/8755
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Chul Lee <chuls.lee@samsung.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
resource/csdk/security/src/aclresource.c

index 3fdba70..04d1108 100644 (file)
@@ -603,8 +603,11 @@ OicSecAcl_t* CBORPayloadToAcl(const uint8_t *cborPayload, const size_t size)
                                         // Permissions -- Mandatory
                                         if (strcmp(name, OIC_JSON_PERMISSION_NAME) == 0)
                                         {
-                                            cborFindResult = cbor_value_get_uint64(&aclMap, (uint64_t *) &acl->permission);
+                                            uint64_t tmp64;
+
+                                            cborFindResult = cbor_value_get_uint64(&aclMap, &tmp64);
                                             VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding a PERM Value.");
+                                            acl->permission = tmp64;
                                         }
 
                                         // Period -- Not mandatory