mkimage: fix option parsing segfault
authorCarlos López <carlos.lopezr4096@gmail.com>
Thu, 24 Apr 2025 15:08:19 +0000 (17:08 +0200)
committerTom Rini <trini@konsulko.com>
Mon, 28 Apr 2025 19:25:59 +0000 (13:25 -0600)
commit2c529839a93d886253c596449545f62bec21a4ac
tree701328ac0c5c58c54502a095b76aca895da8be91
parent23e7088dde1a182bbc6b75bc642ee789f23429b2
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>
tools/mkimage.c