fix what appears to me to be absolutle bogus code

to do with netmasks.. we fed totally bogus data into the kernel
to do with default routes and it just believed us. this led to:
1/ kernel panics
2/ the default route refusing to be deleted or added
(depending on a number of factors, usually it worked ok.)
This commit is contained in:
Julian Elischer 1997-07-18 09:05:12 +00:00
parent 85cfd1244c
commit ba68720f4f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=27500

View File

@ -43,7 +43,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)route.c 8.3 (Berkeley) 3/19/94";
*/
static const char rcsid[] =
"$Id: route.c,v 1.24 1997/04/02 17:05:30 phk Exp $";
"$Id: route.c,v 1.25 1997/06/18 06:30:34 charnier Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -763,7 +763,6 @@ getaddr(which, s, hpp)
switch (which) {
case RTA_DST:
su = &so_dst;
su->sa.sa_family = af;
break;
case RTA_GATEWAY:
su = &so_gate;
@ -809,7 +808,6 @@ getaddr(which, s, hpp)
return(1);
}
}
su->sa.sa_family = af;
break;
case RTA_NETMASK:
su = &so_mask;
@ -819,26 +817,29 @@ getaddr(which, s, hpp)
break;
case RTA_IFP:
su = &so_ifp;
su->sa.sa_family = af;
break;
case RTA_IFA:
su = &so_ifa;
su->sa.sa_family = af;
break;
default:
usage("Internal Error");
/*NOTREACHED*/
}
su->sa.sa_len = aflen;
su->sa.sa_family = af; /* cases that don't want it have left already */
if (strcmp(s, "default") == 0) {
/*
* Default is net 0.0.0.0/0
*/
switch (which) {
case RTA_DST:
forcenet++;
/* bzero(su, sizeof(*su)); *//* for readability */
(void) getaddr(RTA_NETMASK, s, 0);
break;
case RTA_NETMASK:
case RTA_GENMASK:
su->sa.sa_len = 0;
/* bzero(su, sizeof(*su)); *//* for readability */
}
return (0);
}