diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-07 03:00:35 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-07 03:00:35 +0000 |
| commit | ea1046dc461e63c4a3de2b77dc141acd23746963 (patch) | |
| tree | a954ad2b4189a20bbc48614b1b118370de1161eb | |
| parent | b98f89c272937d06b6ead969f3dac6ba94fe0551 (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.c | 8 |
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 |
