From d2c29e771e3a29daf7a23f6ea8406bca7b1fee7e Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Tue, 11 Feb 2025 13:30:23 +0000 Subject: [PATCH] mgmt: mcumgr: smp: Fix custom payload size Fixes an issue when using custom payloads where the size was still using the zcbor buffer instead of the size of the network buffer Signed-off-by: Jamie McCrae --- subsys/mgmt/mcumgr/smp/src/smp.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/subsys/mgmt/mcumgr/smp/src/smp.c b/subsys/mgmt/mcumgr/smp/src/smp.c index 693a26f4d1fd..0da3815907d1 100644 --- a/subsys/mgmt/mcumgr/smp/src/smp.c +++ b/subsys/mgmt/mcumgr/smp/src/smp.c @@ -310,9 +310,15 @@ static int smp_handle_single_req(struct smp_streamer *streamer, const struct smp } #endif - smp_make_rsp_hdr(req_hdr, &rsp_hdr, - zsp->payload_mut - nbw->nb->data - MGMT_HDR_SIZE); - nbw->nb->len = zsp->payload_mut - nbw->nb->data; +#if defined(CONFIG_MCUMGR_MGMT_CUSTOM_PAYLOAD) + if (!mgmt_find_group(req_hdr->nh_group)->custom_payload) { +#endif + nbw->nb->len = zsp->payload_mut - nbw->nb->data; +#if defined(CONFIG_MCUMGR_MGMT_CUSTOM_PAYLOAD) + } +#endif + + smp_make_rsp_hdr(req_hdr, &rsp_hdr, (nbw->nb->len - MGMT_HDR_SIZE)); smp_write_hdr(streamer, &rsp_hdr); return 0;