summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-07 03:00:35 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-07 03:00:35 +0000
commitea1046dc461e63c4a3de2b77dc141acd23746963 (patch)
treea954ad2b4189a20bbc48614b1b118370de1161eb
parentb98f89c272937d06b6ead969f3dac6ba94fe0551 (diff)
util/nvmutil: unambiguous sign conv_argv_part_num
yeah, do the verification manually, don't convert to size_t. this avoids a bunch of theoretical bugs that i can't be bothered to explain at 3AM just trust me bro Signed-off-by: Leah Rowe <leah@libreboot.org>
-rw-r--r--util/nvmutil/nvmutil.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 7bd61704..3f08d932 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -331,10 +331,12 @@ conv_argv_part_num(const char *part_str)
if (part_str[0] == '\0' || part_str[1] != '\0')
err(EINVAL, "Partnum string '%s' wrong length", part_str);
- ch = (unsigned char)part_str[0] - '0';
+ ch = (unsigned char)part_str[0];
- check_part_num((size_t)ch);
- return (size_t)ch;
+ if (ch < '0' || ch > '1')
+ err(EINVAL, "Bad part number (%c)", ch);
+
+ return (size_t)(ch - '0');
}
static void