Subject: bin/2579: traceroute '-s x.x.x.x' fails
To: None <gnats-bugs@NetBSD.ORG>
From: Peter Galbavy <peter@wonderland.org>
List: netbsd-bugs
Date: 06/28/1996 12:54:59
>Number: 2579
>Category: bin
>Synopsis: traceroute -s fails due to wrong condition test of inet_ntoa return value
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Jun 28 08:05:01 1996
>Last-Modified:
>Originator: Peter Galbavy
>Organization:
Wonderland
>Release: 960627
>Environment:
System: NetBSD alice.wonderland.org 1.2_ALPHA NetBSD 1.2_ALPHA (GENERIC_SCSI3) #0: Mon Jun 10 20:24:50 BST 1996 peter@alice.wonderland.org:/dumpty/work/netbsd/src/sys/arch/sparc/compile/GENERIC_SCSI3 sparc
>Description:
On a machine with multiple network interfaces, traceroute -s is supposed to
set the source address for the outgoing packets (lets people test routeing
etc when the return path is not necessarily valid). This fails with the
message: 'traceroute: unknown host x.x.x.x'
This also highlights one of two things - (a) I cannot read, 'cause (b)
when I read the inet_ntoa() man page I cannot see any mention of return values.
>How-To-Repeat:
traceroute -s >any valid ip address on you system< world.std.com
>Fix:
The test condition in traceroute.c for a return from inet_ntoa() is backwards.
Patch below:
*** traceroute.c.old Fri Jun 28 13:58:02 1996
--- traceroute.c Fri Jun 28 13:52:37 1996
***************
*** 462,468 ****
if (source) {
(void) memset(&from, 0, sizeof(struct sockaddr));
from.sin_family = AF_INET;
! if (inet_aton(source, &from.sin_addr) != 0)
errx(1, "unknown host %s", source);
ip->ip_src = from.sin_addr;
#ifndef IP_HDRINCL
--- 462,468 ----
if (source) {
(void) memset(&from, 0, sizeof(struct sockaddr));
from.sin_family = AF_INET;
! if (inet_aton(source, &from.sin_addr) == 0)
errx(1, "unknown host %s", source);
ip->ip_src = from.sin_addr;
#ifndef IP_HDRINCL
>Audit-Trail:
>Unformatted: