util/nvmutil: do cmd bound check

instead of simply checking null, just do a bound check.

this would also cover NULL (-1)

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-08 03:26:51 +00:00
parent ccc58cefbb
commit de1963fdee
+15 -2
View File
@@ -350,8 +350,21 @@ set_cmd_args(int argc, char *argv[])
part = conv_argv_part_num(argv[3]);
}
if (cmd == CMD_NULL)
err(EINVAL, "Bad command");
/*
* This will never actually run.
* It's put here as a guard against
* future regressions by maintainers.
*
* The reason this shouldn't run is
* because when a bad command (or no
* command) is given, either the command
* should be treated as a MAC address,
* or if no command is given, a random
* MAC address is used.
*/
if ((size_t)cmd >= items(command))
err(EINVAL, "Unhandled command error");
}
static size_t