Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Mar 1997 15:18:20 -0500 (EST)
From:      "Mark J. Taylor" <root@spiffy.cybernet.com>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/2898: arp -a -n buglet
Message-ID:  <199703062018.PAA01628@spiffy.cybernet.com>
Resent-Message-ID: <199703062020.MAA09273@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         2898
>Category:       bin
>Synopsis:       arp -a -n buglet
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar  6 12:20:01 PST 1997
>Last-Modified:
>Originator:     Mark J. Taylor
>Organization:
Cybernet Systems Corporation
>Release:        FreeBSD 2.2-GAMMA i386
>Environment:

	FreeBSD-2.2 GAMMA

>Description:

	There is a bug in /usr/sbin/arp which causes it to ignore the "-n"
	option when it is specified as a non-first option: the software exits
	before it has a chance to evalute it (in the case of "arp -a -n").

>How-To-Repeat:

	"arp -a -n" goes to DNS server (if /etc/host.conf specifies that
	first)

>Fix:
	
Here's my patch to usr.sbin/arp/arp.c, from the source labeled:

static char const sccsid[] = "@@(#)from: arp.c  8.2 (Berkeley) 1/2/94";
static char const freebsdid[] = "$Id: arp.c,v 1.4 1996/02/08 21:05:52 phk Exp $";

I've tested these patches, and they seem OK.

This patch also allows the ARPing of mutiple hosts in one line,
as in "arp xxx yyy zzz" as opposed to the old "arp xxx ; arp yyy;
arp zzz".


The man page needs to be updated to reflect the use of the "-n"
option.  Currently it is undocumented.


*** arp.c	1997/03/06 19:41:39	1.1
--- arp.c	1997/03/06 19:51:55
***************
*** 92,97 ****
--- 92,98 ----
  extern int errno;
  static int pid;
  static int nflag;
+ static int all;
  static int s = -1;
  
  int
***************
*** 100,127 ****
  	char **argv;
  {
  	int ch;
  
  	pid = getpid();
  	while ((ch = getopt(argc, argv, "andfsS")) != EOF)
  		switch((char)ch) {
  		case 'a':
! 			dump(0);
! 			exit(0);
  		case 'd':
  			if (argc < 3 || argc > 4)
  				usage();
! 			delete(argv[2], argv[3]);
  			exit(0);
  		case 'n':
  			nflag = 1;
  			continue;
  		case 'S':
! 			delete(argv[2], NULL);
  			/* FALL THROUGH */
  		case 's':
  			if (argc < 4 || argc > 7)
  				usage();
! 			exit(set(argc-2, &argv[2]) ? 1 : 0);
  		case 'f' :
  			if (argc != 3)
  				usage();
--- 101,131 ----
  	char **argv;
  {
  	int ch;
+ 	int pcount=1;
  
  	pid = getpid();
  	while ((ch = getopt(argc, argv, "andfsS")) != EOF)
  		switch((char)ch) {
  		case 'a':
! 			all = 1;
! 			pcount++;
! 			continue;
  		case 'd':
  			if (argc < 3 || argc > 4)
  				usage();
! 			delete(argv[pcount+1], argv[pcount+2]);
  			exit(0);
  		case 'n':
  			nflag = 1;
+ 			pcount++;
  			continue;
  		case 'S':
! 			delete(argv[++pcount], NULL);
  			/* FALL THROUGH */
  		case 's':
  			if (argc < 4 || argc > 7)
  				usage();
! 			exit(set(argc-pcount, &argv[pcount]) ? 1 : 0);
  		case 'f' :
  			if (argc != 3)
  				usage();
***************
*** 129,138 ****
  		case '?':
  		default:
  			usage();
  		}
  	if (argc != 2)
  		usage();
! 	get(argv[1]);
  	exit(0);
  }
  
--- 133,150 ----
  		case '?':
  		default:
  			usage();
+ 			exit(0);
  		}
+ 	if (all) {
+ 		dump(0);
+ 		exit(0);
+ 	}
+ /*
  	if (argc != 2)
  		usage();
! */
! 	while (pcount<argc)
! 		get(argv[pcount++]);
  	exit(0);
  }
  
***************
*** 217,222 ****
--- 229,235 ----
  			herror((char *)NULL);
  			return (1);
  		}
+ 		else
  		bcopy((char *)hp->h_addr, (char *)&sin->sin_addr,
  		    sizeof sin->sin_addr);
  	}
***************
*** 298,305 ****
  		if (!(hp = gethostbyname(host))) {
  			fprintf(stderr, "arp: %s: ", host);
  			herror((char *)NULL);
! 			exit(1);
  		}
  		bcopy((char *)hp->h_addr, (char *)&sin->sin_addr,
  		    sizeof sin->sin_addr);
  	}
--- 311,319 ----
  		if (!(hp = gethostbyname(host))) {
  			fprintf(stderr, "arp: %s: ", host);
  			herror((char *)NULL);
! 			return; /*exit(1);*/
  		}
+ 		else
  		bcopy((char *)hp->h_addr, (char *)&sin->sin_addr,
  		    sizeof sin->sin_addr);
  	}
***************
*** 307,313 ****
  	if (found_entry == 0) {
  		printf("%s (%s) -- no entry\n",
  		    host, inet_ntoa(sin->sin_addr));
! 		exit(1);
  	}
  }
  
--- 321,327 ----
  	if (found_entry == 0) {
  		printf("%s (%s) -- no entry\n",
  		    host, inet_ntoa(sin->sin_addr));
! 		/*exit(1);*/
  	}
  }
  
***************
*** 333,338 ****
--- 347,353 ----
  			herror((char *)NULL);
  			return (1);
  		}
+ 		else
  		bcopy((char *)hp->h_addr, (char *)&sin->sin_addr,
  		    sizeof sin->sin_addr);
  	}
***************
*** 386,391 ****
--- 401,407 ----
  	extern int h_errno;
  	struct hostent *hp;
  
+ 	found_entry = 0;
  	mib[0] = CTL_NET;
  	mib[1] = PF_ROUTE;
  	mib[2] = 0;



>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199703062018.PAA01628>