Skip to content
Commit 865f1d07 authored by Piotr Dymacz's avatar Piotr Dymacz Committed by Jamie McCrae
Browse files

boot_serial: fix image number handle in image upload request



According to the SMP protocol documentation [1], 'image number' value
in 'image upload request' is optional and can be included only in packet
with 'off' (data offset) set to '0' (first packet in upload request).

In one of recent changes (commit 'cb07e888'), initialization of the
'img_num' variable was removed which, in extreme case (no image number
provided in upload request), results in use of its uninitialized value
in flash_area_open() call which then might lead to request abort.

This fixes above regression and also makes MCUboot implementation of the
'image upload request' aligned with Zephyr documentation of the protocol
by considering image number only from first (off == 0) 'image upload
request' SMP packet. In addition, 'image number' value is set to '0' if
the request doesn't provide this field.

[1] docs.zephyrproject.org/latest/services/device_mgmt/smp_groups/smp_group_1.html

Fixes: cb07e888 ("boot_serial: Replace cbor auto-generated code with zcbor functions")
Signed-off-by: default avatarPiotr Dymacz <pepe2k@gmail.com>
(cherry picked from commit 6a8746d7)
parent fb2ff1db
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment