NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/57046: route get fails for hostname "x1".



>Number:         57046
>Category:       lib
>Synopsis:       When "route get" for hostname of /x[0-9a-f][0-9a-f]/, such as x1 or xab, get "route: writing to routing socket: not in table" error.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 06 05:50:00 +0000 2022
>Originator:     Ryo Shimizu
>Release:        NetBSD 9.99.90
>Organization:
>Environment:
System: NetBSD moveq 9.99.90 NetBSD 9.99.90 (GENERIC.PF.NOMPSAFE) #8: Tue Oct 5 21:25:47 JST 2021 ryo@subq:/usr/src/sys/arch/amd64/compile/GENERIC.PF.NOMPSAFE amd64
Architecture: x86_64
Machine: amd64
>Description:
The problem seems to be that inet_network(3) resolves names beginning with 'x'.
For example, inet_network("x99") returns 0x99, but it should return 0xffffffff. (INADDR_NONE)

>How-To-Repeat:
# echo 127.0.0.1 x1 >> /etc/hosts
# route get x1
route: writing to routing socket: not in table

>Fix:
diff --git a/lib/libc/inet/inet_network.c b/lib/libc/inet/inet_network.c
index 135675d5812..38ba4b98342 100644
--- a/lib/libc/inet/inet_network.c
+++ b/lib/libc/inet/inet_network.c
@@ -71,10 +71,11 @@ inet_network(const char *cp)
 
 again:
 	val = 0; base = 10; digit = 0;
-	if (*cp == '0')
+	if (*cp == '0') {
 		digit = 1, base = 8, cp++;
-	if (*cp == 'x' || *cp == 'X')
-		digit = 0, base = 16, cp++;
+		if (*cp == 'x' || *cp == 'X')
+			digit = 0, base = 16, cp++;
+	}
 	while ((c = *cp) != 0) {
 		if (isdigit(c)) {
 			if (base == 8 && (c == '8' || c == '9'))



Home | Main Index | Thread Index | Old Index