git: fedfb4a7fd1e - stable/15 - mkimg: Don't ignore invalid partition offsets

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Wed, 28 Oct 2026 05:52:36 UTC
The branch stable/15 has been updated by cperciva:

URL: https://cgit.FreeBSD.org/src/commit/?id=fedfb4a7fd1e725dead64116100741c26e7e0243

commit fedfb4a7fd1e725dead64116100741c26e7e0243
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2026-10-06 21:22:07 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2026-10-28 01:13:01 +0000

    mkimg: Don't ignore invalid partition offsets
    
    When handling PART_KIND_FILE, the "error" variable is set to reflect
    any errors in parsing the specified offset; but that value is then
    overwritten by the return value of image_copyin.
    
    Error out immediately instead.  Note that it is not necessary to change
    the code in PART_KIND_SIZE which parses the size, since in that case we
    do not overwrite the value in "error".
    
    Fixes:          8f3c71c85e5f ("mkimg: Add support for offset if the source is an image")
    MFC after:      1 week
    Sponsored by:   Amazon
    Differential Revision:  https://reviews.freebsd.org/D60422
    
    (cherry picked from commit e7f84fe6cfac2de3471e4912b1ac82023976ccfa)
---
 usr.bin/mkimg/mkimg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.bin/mkimg/mkimg.c b/usr.bin/mkimg/mkimg.c
index 39117f5f5379..a1881b114b7f 100644
--- a/usr.bin/mkimg/mkimg.c
+++ b/usr.bin/mkimg/mkimg.c
@@ -531,7 +531,7 @@ mkimg(void)
 			else
 				offset++;
 			if (expand_number(offset, &byteoffset) == -1)
-				error = errno;
+				err(EX_IOERR, "partition %d", part->index + 1);
 		}
 
 		/* Work out exactly where the partition starts. */