NetBSD Problem Report #57046
From ryo@ara.nerv.org Thu Oct 6 05:50:00 2022
Return-Path: <ryo@ara.nerv.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id D8FBA1A923C
for <gnats-bugs@gnats.NetBSD.org>; Thu, 6 Oct 2022 05:49:59 +0000 (UTC)
Message-Id: <20221006054953.D6AC25ECEE@ara.nerv.org>
Date: Thu, 6 Oct 2022 14:49:53 +0900 (JST)
From: ryo@nerv.org
Reply-To: ryo@nerv.org
To: gnats-bugs@NetBSD.org
Subject: route get fails for hostname "x1".
X-Send-Pr-Version: 3.95
>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: ryo
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Oct 06 05:50:00 +0000 2022
>Closed-Date: Thu Oct 06 06:29:06 +0000 2022
>Last-Modified: Thu Oct 06 06:29:06 +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'))
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: lib-bug-people->ryo
Responsible-Changed-By: ryo@NetBSD.org
Responsible-Changed-When: Thu, 06 Oct 2022 06:11:45 +0000
Responsible-Changed-Why:
mine
From: "Ryo Shimizu" <ryo@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/57046 CVS commit: src/tests/lib/libc/inet
Date: Thu, 6 Oct 2022 06:05:31 +0000
Module Name: src
Committed By: ryo
Date: Thu Oct 6 06:05:31 UTC 2022
Modified Files:
src/tests/lib/libc/inet: t_inet_network.c
Log Message:
add tests for PR/57046.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/inet/t_inet_network.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: ryo@NetBSD.org
State-Changed-When: Thu, 06 Oct 2022 06:29:06 +0000
State-Changed-Why:
fixed
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2022
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.