From: Carlos López Date: Thu, 24 Apr 2025 15:08:19 +0000 (+0200) Subject: mkimage: fix option parsing segfault X-Git-Tag: v2025.07-rc1~2 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c529839a93d886253c596449545f62bec21a4ac;p=pandora-u-boot.git mkimage: fix option parsing segfault getopt_long() expects a NULL-terminated list of structures. The current list in mkimage does not have a zero-filled structure at the end, which can cause getopt_long() to walk past the end of the array when passing an unknown option, causing a segmentation fault. As a reproducer, the following command causes a segmentation fault (tested in Debian 12): mkimage --foobar Signed-off-by: Carlos López --- diff --git a/tools/mkimage.c b/tools/mkimage.c index ac62ebbde9b..2954626a283 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -196,6 +196,7 @@ static const struct option longopts[] = { { "verbose", no_argument, NULL, 'v' }, { "version", no_argument, NULL, 'V' }, { "xip", no_argument, NULL, 'x' }, + { /* sentinel */ }, }; static void process_args(int argc, char **argv)