From d88991f6bcd5def3790128c157ab32a8dfe61c3a Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 3 Mar 2026 19:18:47 +0000 Subject: 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 --- util/nvmutil/nvmutil.c | 5 +++-- 1 file 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; } } -- cgit v1.2.1