From adam@veda.is  Fri Nov  1 20:41:24 1996
Received: from veda.is (root@ubiq.veda.is [193.4.230.60])
          by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id UAA21681
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 1 Nov 1996 20:41:22 -0800 (PST)
Received: (from adam@localhost) by veda.is (8.8.2/8.7.3) id EAA00669; Sat, 2 Nov 1996 04:41:15 GMT
Message-Id: <199611020441.EAA00669@veda.is>
Date: Sat, 2 Nov 1996 04:41:15 GMT
From: Adam David <adam@veda.is>
Reply-To: adam@veda.is
To: FreeBSD-gnats-submit@freebsd.org
Subject: route(8) args
X-Send-Pr-Version: 3.2

>Number:         1943
>Category:       bin
>Synopsis:       route(8) args
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov  1 20:50:02 PST 1996
>Closed-Date:    Thu Jan 6 01:41:14 PST 2000
>Last-Modified:  Thu Jan  6 01:43:23 PST 2000
>Originator:     Adam David
>Release:        FreeBSD 2.2-CURRENT i386
>Organization:
Veda Internet
>Environment:

	network

>Description:

	The commandline is not parsed very accurately, and this can
	produce bogus results. Also, it is non-obvious how to remove
	a lock (omit the -lock keyword and specify the value 0).

>How-To-Repeat:

	try the following:

	root# route change default -lock                 # does nothing
	root# route change default -lock -mtu            # segmentation fault
	root# route change default -lock -mtu garbage    # -lock -mtu 0
	root# route change default -mtu                  # segmentation fault
	root# route change default -mtu garbage          # -mtu 0

>Fix:
	
	don't rely so heavily on atoi() to DTRT

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->suspended 
State-Changed-By: phk 
State-Changed-When: Mon May 25 00:49:53 PDT 1998 
State-Changed-Why:  
Awaiting committer 

From: adrian@freebsd.org
To: freebsd-gnats-submit@freebsd.org
Cc: Adam David <adam@veda.is>
Subject: Re: bin/1943: route(8) args
Date: Sun, 19 Sep 1999 04:21:01 +0800

 It doesn't seem to segfault now - the checks are stringer,
 however the atoi() isn't too nice. Here's a patch to fix
 that.
 
 Apply it, see if it works, and get back to me as to whether
 we can close this PR or not.
 
 
 
 Adrian
 
 
 
 
 Index: route.c
 ===================================================================
 RCS file: /home/ncvs/src/sbin/route/route.c,v
 retrieving revision 1.32
 diff -u -r1.32 route.c
 --- route.c	1999/08/28 00:14:13	1.32
 +++ route.c	1999/09/18 20:22:18
 @@ -479,6 +479,7 @@
  {
  	int flag = 0;
  	u_long noval, *valp = &noval;
 +	char *endp;
  
  	switch (key) {
  #define caseof(x, y, z)	case x: valp = &rt_metrics.z; flag = y; break
 @@ -496,7 +497,10 @@
  		rt_metrics.rmx_locks |= flag;
  	if (locking)
  		locking = 0;
 -	*valp = atoi(value);
 +	/* check to make sure its a number */
 +	*valp = strtoul(value, &endp, 10);
 +	if (*endp != NULL)
 +		errx(EX_DATAERR, "Invalid non-numerical value '%s'", value);
  }
  
  void
 

From: adrian@freebsd.org
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: bin/1943 route(8) args
Date: Mon, 20 Sep 1999 05:55:35 +0800

 Whoops that should be a *endp != '\0', not NULL.
 ..
 
 
 
State-Changed-From-To: suspended->closed 
State-Changed-By: ru 
State-Changed-When: Thu Jan 6 01:41:14 PST 2000 
State-Changed-Why:  
Fixed a long ago in src/sbin/route/route.c (revs 1.30 and 1.29.2.1). 
>Unformatted:

	aargh, I'm falling asleep here...  that's route(8) in the synopsis
