diff options
author | Carlos López <carlos.lopezr4096@gmail.com> | 2025-04-24 17:08:19 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2025-04-28 13:25:59 -0600 |
commit | 2c529839a93d886253c596449545f62bec21a4ac (patch) | |
tree | 701328ac0c5c58c54502a095b76aca895da8be91 | |
parent | 23e7088dde1a182bbc6b75bc642ee789f23429b2 (diff) |
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 <carlos.lopezr4096@gmail.com>
-rw-r--r-- | tools/mkimage.c | 1 |
1 files changed, 1 insertions, 0 deletions
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) |