From 616099edade1d43893564177cbd31ff5f1c7eea0 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 24 Mar 2026 04:43:52 +0000 Subject: util/nvmutil: make it compile again i was reorganising the state machine (singleton) used for data, and part of what i wanted lead to mkhtemp being written. Signed-off-by: Leah Rowe --- util/libreboot-utils/lib/command.c | 1 + util/libreboot-utils/lib/state.c | 15 +++++---------- util/libreboot-utils/nvmutil.c | 8 ++++++++ 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'util/libreboot-utils') diff --git a/util/libreboot-utils/lib/command.c b/util/libreboot-utils/lib/command.c index 3a863d23..94840191 100644 --- a/util/libreboot-utils/lib/command.c +++ b/util/libreboot-utils/lib/command.c @@ -127,6 +127,7 @@ set_cmd(int argc, char *argv[]) "Too few args on command '%s'", cmd); } + x->no_cmd = 1; } diff --git a/util/libreboot-utils/lib/state.c b/util/libreboot-utils/lib/state.c index f9be230f..a3ad0f1e 100644 --- a/util/libreboot-utils/lib/state.c +++ b/util/libreboot-utils/lib/state.c @@ -105,14 +105,10 @@ xstart(int argc, char *argv[]) us.f.tmp_fd = -1; us.f.tname = NULL; + if (new_tmpfile(&us.f.tmp_fd, &us.f.tname) < 0) err_no_cleanup(errno, "%s", us.f.tname); - /* parse user command */ -/* TODO: CHECK ACCESSES VIA xstatus() */ - set_cmd(argc, argv); - set_cmd_args(argc, argv); - if (us.f.tname == NULL) err_no_cleanup(errno, "x->f.tname null"); if (*us.f.tname == '\0') @@ -138,8 +134,6 @@ xstatus(void) if (x == NULL) err_no_cleanup(EACCES, "NULL pointer to xstate"); - sanitize_command_list(); - return x; } @@ -180,10 +174,11 @@ getnvmprogname(void) char *rval = fallback; if (x != NULL) { - if (x->argv0 == NULL || *x->argv0 == '\0') - return ""; - rval = x->argv0; + if (x->argv0 != NULL && *x->argv0 != '\0') + rval = x->argv0; + else + return fallback; } p = strrchr(rval, '/'); diff --git a/util/libreboot-utils/nvmutil.c b/util/libreboot-utils/nvmutil.c index cb08ec43..fa6384b0 100644 --- a/util/libreboot-utils/nvmutil.c +++ b/util/libreboot-utils/nvmutil.c @@ -62,6 +62,11 @@ main(int argc, char *argv[]) if (x == NULL) err_no_cleanup(ECANCELED, "NULL state on init"); + /* parse user command */ +/* TODO: CHECK ACCESSES VIA xstatus() */ + set_cmd(argc, argv); + set_cmd_args(argc, argv); + cmd = &x->cmd[x->i]; f = &x->f; @@ -96,6 +101,9 @@ main(int argc, char *argv[]) if (cmd->run == NULL) err(errno, "Command not set"); + + sanitize_command_list(); + open_gbe_file(); copy_gbe(); -- cgit v1.2.1