From c393b5424699ba9f05a936cff830d8e2ed3f953d Mon Sep 17 00:00:00 2001 From: Daniel DeGrasse Date: Tue, 23 May 2023 21:52:09 +0000 Subject: [PATCH] boot: boot_serial: fix usage of zcbor_new_encode_state API Fix usage of zcbor_new_encode_state API, to correctly pass the payload length. The previous usage was passing a pointer to the end of the payload, which resulted in the ZCBOR structure being initialized with an invalid `payload_end` field. On some platforms, this breaks MCUBoot serial recovery, as the ZCBOR structures required to send response data are invalid and can no longer be populated with response data. Signed-off-by: Daniel DeGrasse --- boot/boot_serial/src/boot_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/boot_serial/src/boot_serial.c b/boot/boot_serial/src/boot_serial.c index 5f83ed27..5b90fa59 100644 --- a/boot/boot_serial/src/boot_serial.c +++ b/boot/boot_serial/src/boot_serial.c @@ -136,7 +136,7 @@ static zcbor_state_t cbor_state[2]; void reset_cbor_state(void) { zcbor_new_encode_state(cbor_state, 2, (uint8_t *)bs_obuf, - (size_t)bs_obuf + sizeof(bs_obuf), 0); + sizeof(bs_obuf), 0); } /**