[PATCH 1/3] Check octets more often in inet_network (bz 32575)

Tobias Stoeckmann tobias@stoeckmann.org
Sun Jan 19 15:02:59 GMT 2025


Make sure that numbers never overflow uint32_t to properly validate
octets encountered in IPv4 addresses.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
---
 inet/inet_net.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/inet/inet_net.c b/inet/inet_net.c
index 50b526705d..13a818176d 100644
--- a/inet/inet_net.c
+++ b/inet/inet_net.c
@@ -69,6 +69,8 @@ again:
 	if (*cp == 'x' || *cp == 'X')
 		digit = 0, base = 16, cp++;
 	while ((c = *cp) != 0) {
+		if (val > 0xff)
+			return (INADDR_NONE);
 		if (isdigit(c)) {
 			if (base == 8 && (c == '8' || c == '9'))
 				return (INADDR_NONE);
--
2.48.1



More information about the Libc-alpha mailing list