diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-03 19:18:47 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-03 19:18:47 +0000 |
| commit | d88991f6bcd5def3790128c157ab32a8dfe61c3a (patch) | |
| tree | 7b120a54af2696996f15a9c164e42c4691fa4325 | |
| parent | bf081914a314cbf8e0e141bfe77751dedcbc021b (diff) | |
util/nvmutil: use strncmp instead of strcmp
set a constant maximum length. this seems reasonable,
and it's even quite generous.
Signed-off-by: Leah Rowe <leah@libreboot.org>
| -rw-r--r-- | util/nvmutil/nvmutil.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index ea8f248c..d60e2cbe 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -69,6 +69,7 @@ static int fd; static int part; static int invert; static int part_modified[2]; +static int max_cmd_length = 50; static const char *mac = NULL; static const char *rmac = "xx:xx:xx:xx:xx:xx"; @@ -145,7 +146,7 @@ set_cmd(int argc, char *argv[]) arg_cmd = argv[2]; for (i = 0; (i < items(ops)) && (cmd == NULL); i++) { - if (strcmp(arg_cmd, ops[i].str) != 0) + if (strncmp(arg_cmd, ops[i].str, max_cmd_length) != 0) continue; if (argc >= ops[i].args) { cmd = ops[i].cmd; @@ -185,7 +186,7 @@ set_io_flags(int argc, char *argv[]) flags = O_RDWR; if (argc > 2) { - if (strcmp(arg_cmd, "dump") == 0) + if (strncmp(arg_cmd, "dump", 50) == 0) flags = O_RDONLY; } } |
