Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
I
iotivity-classic
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,289
    • Issues 3,289
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • IoTivity
  • iotivity-classic
  • Issues
  • #2552

Closed
Open
Opened Nov 05, 2019 by Rami Alshafi@ramiOwner

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

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: iotivity/iotivity-classic#2552