Avoid the crash by checking whether the cbortype is map.
Fundamentally, no-cbor type payload should be filtered in tinycbor library.
This change can be removed later.
Change-Id: Icde1422c61319d8c5e66675d9ef2b66f30dc4077
Signed-off-by: Markus Jung <markus.jung@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/7737
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Reviewed-by: Markus Jung <markus.jung85@gmail.com>
(cherry picked from commit
d237eecb9b581157dee9c3314d5a07091b0078ed)
Reviewed-on: https://gerrit.iotivity.org/gerrit/7835
Reviewed-by: Habib Virji <habib.virji@samsung.com>
CborValue curVal;
ret = OC_STACK_MALFORMED_RESPONSE;
+ // temporary fix to check for malformed cbor payload
+ if (!cbor_value_is_map(&rootMap) && !cbor_value_is_array(&rootMap)){
+ goto exit;
+ }
+
if (cbor_value_is_map(&rootMap))
{
err = cbor_value_map_find_value(&rootMap, OC_RSRVD_HREF, &curVal);
VERIFY_CBOR_SUCCESS(TAG, err, "Failed to find uri");
}
}
+
// Resource types
if (cbor_value_is_map(&rootMap))
{
err = OCParseSingleRepPayload(&temp, &rootMap, true);
VERIFY_CBOR_SUCCESS(TAG, err, "Failed to parse single rep payload");
}
+
if(rootPayload == NULL)
{
rootPayload = temp;