Subject: bin/4074: "route flush" handles empty routing table wrong
To: None <gnats-bugs@gnats.netbsd.org>
From: Matthias Scheler <tron@lyssa.owl.de>
List: netbsd-bugs
Date: 09/02/1997 01:42:59
>Number:         4074
>Category:       bin
>Synopsis:       "route flush" handles empty routing table wrong
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Sep  1 16:50:01 1997
>Last-Modified:
>Originator:     Matthias Scheler
>Organization:
Matthias Scheler                                http://home.owl.de/~tron/
>Release:        97028
>Environment:
System: NetBSD lyssa 1.2G NetBSD 1.2G (LYSSA) #0: Fri Aug 29 12:08:23 MEST 1997 tron@lyssa:/usr/src/sys/arch/i386/compile/LYSSA i386


>Description:
While system startup "route" prints a confusing error message if
"flushroutes" is set to "YES" in "/etc/rc.conf":

route: actual retrieval of routing table: Bad address

The reason is that it isn't able to handle an uninitialized routing table.

>How-To-Repeat:
Watch a NetBSD system which calls "route flush" while booting.

>Fix:
*** route.c.orig	Mon Apr 28 13:15:26 1997
--- route.c	Tue Sep  2 01:26:47 1997
*************** bad:			usage(*argv);
*** 281,286 ****
--- 281,287 ----
  	mib[5] = 0;		/* no flags */
  	if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
  		quit("route-sysctl-estimate");
+ 	if (needed == 0) return;
  	if ((buf = malloc(needed)) == NULL)
  		quit("malloc");
  	if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0)

>Audit-Trail:
>Unformatted: