diff options
author | hrs <hrs@FreeBSD.org> | 2013-08-01 04:50:46 +0000 |
---|---|---|
committer | hrs <hrs@FreeBSD.org> | 2013-08-01 04:50:46 +0000 |
commit | ae539b49caf1adee4cd732dfedf805927f64a692 (patch) | |
tree | 91ef8443923f8e2dd54609adf5c4992319b97652 /sbin | |
parent | 5d2ce17ff01a410d5962062771ae1e121fbd92c1 (diff) | |
download | FreeBSD-src-ae539b49caf1adee4cd732dfedf805927f64a692.zip FreeBSD-src-ae539b49caf1adee4cd732dfedf805927f64a692.tar.gz |
Fix boundary check of sockaddr array.
Reported by: uqs
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/route/route.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c index ebf95c6..e575c71 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; |