[klibc] [klibc:master] inet: Fix character type test in inet_pton()
klibc-bot for Ben Hutchings
ben at decadent.org.uk
Thu Mar 21 15:36:13 PDT 2024
Commit-ID: d4821f1d5417be8d8ecb7eb90a0def34c384b5bd
Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=d4821f1d5417be8d8ecb7eb90a0def34c384b5bd
Author: Ben Hutchings <ben at decadent.org.uk>
AuthorDate: Thu, 21 Mar 2024 22:19:40 +0100
Committer: Ben Hutchings <ben at decadent.org.uk>
CommitDate: Thu, 21 Mar 2024 23:27:49 +0100
[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 at decadent.org.uk>
---
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 2df6b677..a319506a 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 */
}
More information about the klibc
mailing list