From 1e3b39d361ff5ca8f8d39952596082ba0c603d34 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Tue, 1 Jun 1999 13:14:07 +0000 Subject: [PATCH] Get rid of segfaults in a set-uid program. PR: 11823 Reviewed by: des --- sbin/route/route.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/sbin/route/route.c b/sbin/route/route.c index 02c6b77e3268..45261b0e1571 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)route.c 8.3 (Berkeley) 3/19/94"; #endif static const char rcsid[] = - "$Id$"; + "$Id: route.c,v 1.29 1998/07/28 06:25:35 charnier Exp $"; #endif /* not lint */ #include @@ -581,28 +581,34 @@ newroute(argc, argv) flags |= RTF_STATIC; break; case K_IFA: - argc--; + if (!--argc) + usage((char *)NULL); (void) getaddr(RTA_IFA, *++argv, 0); break; case K_IFP: - argc--; + if (!--argc) + usage((char *)NULL); (void) getaddr(RTA_IFP, *++argv, 0); break; case K_GENMASK: - argc--; + if (!--argc) + usage((char *)NULL); (void) getaddr(RTA_GENMASK, *++argv, 0); break; case K_GATEWAY: - argc--; + if (!--argc) + usage((char *)NULL); (void) getaddr(RTA_GATEWAY, *++argv, 0); break; case K_DST: - argc--; + if (!--argc) + usage((char *)NULL); ishost = getaddr(RTA_DST, *++argv, &hp); dest = *argv; break; case K_NETMASK: - argc--; + if (!--argc) + usage((char *)NULL); (void) getaddr(RTA_NETMASK, *++argv, 0); /* FALLTHROUGH */ case K_NET: @@ -616,7 +622,8 @@ newroute(argc, argv) case K_SSTHRESH: case K_RTT: case K_RTTVAR: - argc--; + if (!--argc) + usage((char *)NULL); set_metric(*++argv, key); break; default: