From 084b08725aad477d6d963afd882aa15a7d3fa198 Mon Sep 17 00:00:00 2001 From: Luca Cominardi Date: Thu, 28 Mar 2024 16:54:33 +0100 Subject: [PATCH] Decode fails when interest id flag is set (#392) --- include/zenoh-pico/protocol/definitions/declarations.h | 2 ++ src/protocol/codec/declarations.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/zenoh-pico/protocol/definitions/declarations.h b/include/zenoh-pico/protocol/definitions/declarations.h index 66e21add2..b40cb3fc4 100644 --- a/include/zenoh-pico/protocol/definitions/declarations.h +++ b/include/zenoh-pico/protocol/definitions/declarations.h @@ -95,6 +95,8 @@ typedef struct { } _z_undecl_interest_t; _z_undecl_interest_t _z_undecl_interest_null(void); +#define _Z_FLAG_INTEREST_ID (1 << 5) + typedef struct { enum { _Z_DECL_KEXPR, diff --git a/src/protocol/codec/declarations.c b/src/protocol/codec/declarations.c index 824965c2d..bb0806a6a 100644 --- a/src/protocol/codec/declarations.c +++ b/src/protocol/codec/declarations.c @@ -427,9 +427,13 @@ int8_t _z_undecl_interest_decode(_z_undecl_interest_t *decl, _z_zbuf_t *zbf, uin return _z_undecl_trivial_decode(zbf, &decl->_ext_keyexpr, &decl->_id, header); } int8_t _z_declaration_decode(_z_declaration_t *decl, _z_zbuf_t *zbf) { - int8_t ret; uint8_t header; _Z_RETURN_IF_ERR(_z_uint8_decode(&header, zbf)); + if (_Z_HAS_FLAG(header, _Z_FLAG_INTEREST_ID)) { + return _Z_ERR_MESSAGE_FLAG_UNEXPECTED; + } + + int8_t ret; switch (_Z_MID(header)) { case _Z_DECL_KEXPR_MID: { decl->_tag = _Z_DECL_KEXPR;