You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2026/10/27 09:39:20 UTC

(mynewt-core) 03/04: net/oic: Check rep type in discovery payload processing

This is an automated email from the ASF dual-hosted git repository.

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 756a88782c73ab2443a3cb5b57fb3cf223a93d20
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Sun Oct 25 20:45:58 2026 +0100

    net/oic: Check rep type in discovery payload processing
    
    Elements of parsed discovery payload were assumed to be objects and
    value_object was used without checking the type. For payload with
    root map, value of e.g. integer property was used as pointer.
    
    Skip elements that are not objects.
    
    Assisted-by: Claude:claude-opus-5-5
---
 net/oic/src/api/oc_discovery.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/oic/src/api/oc_discovery.c b/net/oic/src/api/oc_discovery.c
index 2f40481d7..39213c876 100644
--- a/net/oic/src/api/oc_discovery.c
+++ b/net/oic/src/api/oc_discovery.c
@@ -209,6 +209,10 @@ oc_ri_process_discovery_payload(struct coap_packet_rx *rsp,
     if (s == 0)
         array = rep;
     while (array != NULL) {
+        if (array->type != OBJECT) {
+            array = array->next;
+            continue;
+        }
         oc_rep_t *device_map = array->value_object;
         while (device_map != NULL) {
             switch (device_map->type) {