diff options
| author | HiFiPhile <[email protected]> | 2025-10-31 10:49:33 +0100 |
|---|---|---|
| committer | HiFiPhile <[email protected]> | 2025-10-31 10:56:31 +0100 |
| commit | cee793796ca6feb2164201c6915592a04bf496d2 (patch) | |
| tree | 138ad2989325fae31ef9ff86a928f087198ec842 | |
| parent | 7c4cc0f7c8f72a9f55a8b301dfab6fc1d0125018 (diff) | |
Add boundary check
Signed-off-by: HiFiPhile <[email protected]>
| -rw-r--r-- | examples/device/dfu/src/main.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/examples/device/dfu/src/main.c b/examples/device/dfu/src/main.c index c0c848837..43e0af9a5 100644 --- a/examples/device/dfu/src/main.c +++ b/examples/device/dfu/src/main.c @@ -187,7 +187,9 @@ uint16_t tud_dfu_upload_cb(uint8_t alt, uint16_t block_num, uint8_t* data, uint1 (void) block_num; (void) length; - uint16_t const xfer_len = (uint16_t) strlen(upload_image[alt]); + TU_VERIFY(block_num == 0, 0); // for this example we only support single block upload + + uint16_t const xfer_len = tu_min16((uint16_t) strlen(upload_image[alt]), length); memcpy(data, upload_image[alt], xfer_len); return xfer_len; |
