NetBSD Problem Report #3876

Received: (qmail 10377 invoked from network); 17 Jul 1997 05:26:48 -0000
Message-Id: <199707170526.AAA07431@dahan.metonymy.com>
Date: Thu, 17 Jul 1997 00:26:28 -0500 (CDT)
From: Dave Huang <khym@bga.com>
Reply-To: khym@bga.com
To: gnats-bugs@gnats.netbsd.org
Subject: ping fails to convert net byte order to host byte order when displaying some values
X-Send-Pr-Version: 3.95

>Number:         3876
>Category:       bin
>Synopsis:       ping fails to convert net byte order to host byte order when displaying some values
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jul 16 22:35:00 +0000 1997
>Closed-Date:    Wed Jul 16 23:40:13 +0000 1997
>Last-Modified:  Thu Jul 17 06:40:29 +0000 1997
>Originator:     Dave Huang
>Release:        NetBSD-current as of July 16, 1997
>Organization:
Name: Dave Huang     |   Mammal, mammal / their names are called /
INet: khym@bga.com   |   they raise a paw / the bat, the cat /
FurryMUCK: Dahan     |   dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 21 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++
>Environment:

System: NetBSD dahan.metonymy.com 1.2G NetBSD 1.2G (SPIFF) #63: Tue Jul 15 19:30:39 CDT 1997 khym@dahan.metonymy.com:/usr/src.local/sys/arch/i386/compile/SPIFF i386


>Description:
When ping receives a packet other than ICMP Echo Reply in response to
its Echo Request, it prints the error along with the echo request's
sequence number. However, it fails to convert it from network byte
order to host byte order before printing it out, so on a little-endian
machine (i386, in this case), you get something like:

PING 10.1.1.1 (10.1.1.1): 56 data bytes
36 bytes from sl-fw-13-S1/0-T1.sprintlink.net (144.228.12.1): Destination Host Unreachable for icmp_seq=0
36 bytes from sl-fw-13-S1/0-T1.sprintlink.net (144.228.12.1): Destination Host Unreachable for icmp_seq=256
36 bytes from sl-fw-13-S1/0-T1.sprintlink.net (144.228.12.1): Destination Host Unreachable for icmp_seq=512

----10.1.1.1 PING Statistics----
3 packets transmitted, 0 packets received, 100% packet loss

>How-To-Repeat:
On a little-endian machine, ping someplace that'll return a host
unreachable. Network 10 seems to do it for me...

>Fix:
This patch also does ntohs on icmp_id... it's just an arbitrary
number, so I guess it doesn't really matter, but I think it's more
"correct" this way :) On the other hand, ping sets icmp_id to it's
process id, without first doing htons, so with the unpatched ping, ID
would always be displayed as the pid of the ping process. I still
think it's nicer this way though :)

--- ping.c~	Thu Jun 26 23:42:22 1997
+++ ping.c	Wed Jul 16 23:46:30 1997
@@ -1511,11 +1511,11 @@
 		if (icp2.icmp_type == ICMP_ECHO) {
 			if (pingflags & F_VERBOSE)
 				(void)printf("\n  ID=%u icmp_seq=%u",
-					     icp2.icmp_id,
-					     icp2.icmp_seq);
+					     ntohs(icp2.icmp_id),
+					     ntohs(icp2.icmp_seq));
 			else
 				(void)printf(" for icmp_seq=%u",
-					     icp2.icmp_seq);
+					     ntohs(icp2.icmp_seq));
 		}
 	}
 }

>Release-Note:
>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: mikel
State-Changed-When: Wed Jul 16 23:40:13 1997
State-Changed-Why:
fixed (mostly) as suggested, thanks.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.