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>
This commit is contained in:
Leah Rowe
2026-03-07 03:00:35 +00:00
parent b98f89c272
commit ea1046dc46

View File

@@ -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