From d4821f1d5417be8d8ecb7eb90a0def34c384b5bd Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 21 Mar 2024 22:19:40 +0100 Subject: [klibc] inet: Fix character type test in inet_pton() The argument to ixdigit() and other ctype functions must be a char value converted to unsigned char, or -1; otherwise the results are undefined. In practice, if char is signed we could passs a value < -1 which would result in an out-of-bounds read. Signed-off-by: Ben Hutchings --- usr/klibc/inet/inet_pton.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/klibc/inet/inet_pton.c b/usr/klibc/inet/inet_pton.c index 2df6b677653f4..a319506abd390 100644 --- a/usr/klibc/inet/inet_pton.c +++ b/usr/klibc/inet/inet_pton.c @@ -43,7 +43,7 @@ int inet_pton(int af, const char *src, void *dst) colons++; if (p[1] == ':') dcolons++; - } else if (!isxdigit(*p)) + } else if (!isxdigit((unsigned char)*p)) return 0; /* Invalid address */ } -- cgit 1.2.3-korg