aboutsummaryrefslogtreecommitdiff
path: root/sbin/route/route.c
diff options
context:
space:
mode:
authorHiroki Sato <hrs@FreeBSD.org>2013-08-01 04:50:46 +0000
committerHiroki Sato <hrs@FreeBSD.org>2013-08-01 04:50:46 +0000
commit15768a8b07f633c477d599b028ffa29e8817dc0f (patch)
tree91ef8443923f8e2dd54609adf5c4992319b97652 /sbin/route/route.c
parent9e1db66eb4b7422dd858d1c2c25ccb71086a1064 (diff)
downloadsrc-15768a8b07f633c477d599b028ffa29e8817dc0f.tar.gz
src-15768a8b07f633c477d599b028ffa29e8817dc0f.zip
Fix boundary check of sockaddr array.
Reported by: uqs
Notes
Notes: svn path=/head/; revision=253852
Diffstat (limited to 'sbin/route/route.c')
-rw-r--r--sbin/route/route.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c
index ebf95c65d8cb..e575c711329f 100644
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -1146,6 +1146,8 @@ getaddr(int idx, char *str, struct hostent **hpp, int nrflags)
char *q;
#endif
+ if (idx < 0 || idx >= RTAX_MAX)
+ usage("internal error");
if (af == 0) {
#if defined(INET)
af = AF_INET;
@@ -1162,9 +1164,6 @@ getaddr(int idx, char *str, struct hostent **hpp, int nrflags)
hpp = NULL;
#endif
rtm_addrs |= (1 << idx);
-
- if (idx > RTAX_MAX)
- usage("internal error");
sa = (struct sockaddr *)&so[idx];
sa->sa_family = af;
sa->sa_len = aflen;