diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2024-03-21 22:19:40 +0100 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2024-03-21 23:27:49 +0100 |
commit | d4821f1d5417be8d8ecb7eb90a0def34c384b5bd (patch) | |
tree | f8d62597f7163d85883b52b10ae9e086fa17a920 | |
parent | f3d4b17ba2afe236cd151a15d7200687e3d2a84f (diff) |
[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 <ben@decadent.org.uk>
-rw-r--r-- | usr/klibc/inet/inet_pton.c | 2 |
1 files changed, 1 insertions, 1 deletions
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 */ } |