[IOT-1849] fixed null subject ID comparison logic
authorNathan Heldt-Sheller <nathan.heldt-sheller@intel.com>
Fri, 24 Feb 2017 19:11:20 +0000 (11:11 -0800)
committerNathan Heldt-Sheller <nathan.heldt-sheller@intel.com>
Sat, 18 Mar 2017 19:32:50 +0000 (19:32 +0000)
commitf5e1970d66078b764b0f6cf59b65663e986411dd
treeb70fe095d0c684da0322bc6b15e1ef7f825ec378
parentd547ed3a8291b86114cca71df7b337a2145c9ad2
[IOT-1849] fixed null subject ID comparison logic

Issue description:
CTT sends requests over coap, but isRequestOverSecureChannel incorrectly concludes
that these requests arrived over a secured channel. That's because here:

if(memcmp(context->requestInfo->info.identity.id,
nullSubjectId.id, sizeof(context->requestInfo->info.identity.id)) != 0)

sizeof(context->requestInfo->info.identity.id) is larger than sizeof(nullSubjectId.id).

So, that compares a bunch of random bytes from the stack with the bytes from
context->requestInfo->info.identity.id.

This changes logic to compare like-sized objects.

patchset 2: resolved IOT-1849; created new IOT-1894 "Determine appropriate CA_MAX_ENDPOINT_IDENTITY_LEN" (see "TODO IOT-1894" comment).

patchset 3: comment typo fix

patchset 4: self review fixes

patchset 5: addressed Dan's feedback

patchset 6: addressed Phil's feedback

patchset 7: replaced if( with if ( throughout

Change-Id: I2781357c74a1e0c47a534bc6df2f2b790c0caae7
Signed-off-by: Nathan Heldt-Sheller <nathan.heldt-sheller@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17503
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Kevin Kane <kkane@microsoft.com>
resource/csdk/security/src/secureresourcemanager.c