libkmipclient: Fix kmip_parse_decimal_uint() to reject negative numbers

Function strtoull() silently accepts a leading '-' and returns a large
positive number (two's complement wrap). Reject this by checking for
the minus character.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Ingo Franzki
2026-07-01 09:06:30 +02:00
committed by Jan Höppner
parent 866324bcd2
commit cc6f1a6d7b

View File

@@ -74,6 +74,8 @@ int kmip_parse_decimal_uint(const char *str, uint64_t *val)
if (str == NULL)
return -EINVAL;
if (str[0] == '-')
return -EBADMSG;
errno = 0;
v = strtoull(str, &endptr, 10);