IoTivity crashes when "rel" is an array in /oic/res
The IUTSumulator app crashes while parsing response to /oic/res if the response contains a link with "rel" being an array. After implementing
BZ #3094
in the CTT, the simulator used in client test cases was updated to pass the new test case introduced in #3094. As part of that update the link to /oic/res was changed from "rel": "self" to "rel": ["self", "item"].
After a quick search in the sources, I've found that the source of this issue is in IoTivity API functions in ocpayloadparse.c which expect the "rel" property to be a string:
OCParseDiscoveryPayloadCbor:
// Rel - Not a mandatory field
err = cbor_value_map_find_value(&resourceMap, OC_RSRVD_REL, &curVal);
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "to find rel tag");
if (cbor_value_is_valid(&curVal))
{
err = cbor_value_dup_text_string(&curVal, &(resource->rel), &len, NULL);
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "to find rel value");
}
ParseResources:
// Rel - Not a mandatory field
err = cbor_value_map_find_value(resourceMap, OC_RSRVD_REL, &curVal);
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "to find rel tag");
if (cbor_value_is_valid(&curVal))
{
err = cbor_value_dup_text_string(&curVal, &(resource->rel), &len, NULL);
VERIFY_CBOR_SUCCESS_OR_OUT_OF_MEMORY(TAG, err, "to find rel value");
}
When the code receives the "rel" as an array, the cbor_value_dup_text_string crashes the app with the following error:
IUTSimulator: extlibs/tinycbor/tinycbor/src/cbor.h:445: cbor_value_dup_text_string: Assertion `cbor_value_is_text_string(value)' failed.
Aborted (core dumped)
As per the current swagger definition of
oic.wk.res
, the "rel" proeprty of a link can be either a string or an array:
"rel": {
"description": "The relation of the target URI referenced by the Link to the context URI",
"oneOf": [
{
"$ref": "https://openconnectivityfoundation.github.io/core/schemas/oic.links.properties.core-schema.json#/definitions/rel_array"
},
{
"$ref": "https://openconnectivityfoundation.github.io/core/schemas/oic.links.properties.core-schema.json#/definitions/rel_string"
}
]
},
The IoTivity API implementation needs to be updated to account for that.
JIRA migration meta data
- JIRA Issue ID: IOT-3303
- Reporter: krzysztof.j.wlodarczyk
- Assignee: nathanheldtsheller
- Creator: krzysztof.j.wlodarczyk
- Created at: 2019-11-05T02:15:05.000-0800
- Found in Version: master
- Fix in Version: None
- Issue Severity: Major
- Reproducibility: Always (100%)
- Operating System: Ubuntu
- Hardware/ OEM Platform: None
- External URL: None
- Bugzilla ID: None
- Product: None
- Status: Open
- Components: Discovery/Connectivity
- Priority: P1
- Due Date: None
-
Issue Type: Bug
END of JIRA migration meta data