This is an automated email from the ASF dual-hosted git repository.

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-mcumgr.git

commit de9fc514c2d51cfbc83308f8cbefeadb2aea7499
Author: Szymon Janc <[email protected]>
AuthorDate: Wed Oct 7 15:46:20 2026 +0200

    cmd/img_mgmt: Add missing data length check
    
    Make sure that image upload data length does not exceed data buffer size
    before writing it to flash.
    
    Assisted-by: Claude:claude-opus-5-5
---
 cmd/img_mgmt/port/mynewt/src/mynewt_img_mgmt.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/cmd/img_mgmt/port/mynewt/src/mynewt_img_mgmt.c 
b/cmd/img_mgmt/port/mynewt/src/mynewt_img_mgmt.c
index b56e3a6..9698193 100644
--- a/cmd/img_mgmt/port/mynewt/src/mynewt_img_mgmt.c
+++ b/cmd/img_mgmt/port/mynewt/src/mynewt_img_mgmt.c
@@ -133,6 +133,10 @@ img_mgmt_impl_upload_inspect(const struct 
img_mgmt_upload_req *req,
         return MGMT_ERR_EINVAL;
     }
 
+    if (req->data_len > sizeof(req->img_data)) {
+        return MGMT_ERR_EINVAL;
+    }
+
     if (req->off == 0) {
         /* First upload chunk. */
         if (req->data_len < sizeof(struct image_header)) {

Reply via email to