From 1a79f20dab74338bb9ce6ee5100a957b73159c00 Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Mon, 24 Feb 2025 13:29:56 -0500 Subject: [PATCH 1/2] Update rrdMsgPackDecoder.c --- src/rrdMsgPackDecoder.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/rrdMsgPackDecoder.c b/src/rrdMsgPackDecoder.c index b63d8d342..e851eaa1f 100644 --- a/src/rrdMsgPackDecoder.c +++ b/src/rrdMsgPackDecoder.c @@ -175,15 +175,14 @@ void *helper_convert(const void *buf, size_t len, msgpack_unpack_return get_msgpack_unpack_status(char *decodedbuf, int size) { - msgpack_zone mempool; - msgpack_object deserialized; + msgpack_unpacked deserialized; + msgpack_unpacked_init(&deserialized); msgpack_unpack_return unpack_ret; if (decodedbuf == NULL || !size) return MSGPACK_UNPACK_NOMEM_ERROR; - msgpack_zone_init(&mempool, 2048); - unpack_ret = msgpack_unpack(decodedbuf, size, NULL, &mempool, &deserialized); + unpack_ret = msgpack_unpack_next(&deserialized, decodedbuf, size, NULL); switch(unpack_ret) { @@ -206,7 +205,7 @@ msgpack_unpack_return get_msgpack_unpack_status(char *decodedbuf, int size) RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Message Pack decode failed with error\n", __FUNCTION__, __LINE__); } - msgpack_zone_destroy(&mempool); + msgpack_unpacked_destroy( &deserialized ); // End of msgpack decoding return unpack_ret; From 15ada8312144596e3ec40b577ed69c223408f80f Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Mon, 24 Feb 2025 13:37:34 -0500 Subject: [PATCH 2/2] Update rrdUnitTestRunner.cpp --- src/unittest/rrdUnitTestRunner.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unittest/rrdUnitTestRunner.cpp b/src/unittest/rrdUnitTestRunner.cpp index 83edda9be..883c80966 100644 --- a/src/unittest/rrdUnitTestRunner.cpp +++ b/src/unittest/rrdUnitTestRunner.cpp @@ -2951,7 +2951,8 @@ TEST(GetMsgpackUnpackStatusTest, MsgpackUnpackReturnsExtraBytes) msgpack_pack_int(&pk, 1); sbuf.data[sbuf.size] = '\0'; // Add an extra byte - EXPECT_EQ(get_msgpack_unpack_status(sbuf.data, sbuf.size + 1), MSGPACK_UNPACK_EXTRA_BYTES); + // msg_unpack_next() internally handles EXTRABYTES. It should return SUCCESS. + EXPECT_EQ(get_msgpack_unpack_status(sbuf.data, sbuf.size + 1), MSGPACK_UNPACK_SUCCESS); msgpack_sbuffer_destroy(&sbuf); }