mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
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>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user