util/nvmutil: call usage if argc below 3

otherwise, we invoke the state machine in weird
conditions, where some pointers may not be initialised.

we could handle this properly, but why?

therefore, the errhook is called after the argc
check.

this patch fixes a Speicherzugriffsfehler that
i got while running nvmutil with below 3 arguments

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-31 17:53:05 +01:00
parent d2abde5303
commit e731893208
+4 -1
View File
@@ -32,8 +32,11 @@ main(int argc, char *argv[])
struct xfile *f;
size_t c;
(void) errhook(exit_cleanup);
(void) lbsetprogname(argv[0]);
if (argc < 3)
usage();
(void) errhook(exit_cleanup);
/* https://man.openbsd.org/pledge.2 */
/* https://man.openbsd.org/unveil.2 */