From 15768a8b07f633c477d599b028ffa29e8817dc0f Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Thu, 1 Aug 2013 04:50:46 +0000 Subject: [PATCH] Fix boundary check of sockaddr array. Reported by: uqs --- sbin/route/route.c | 5 ++--- 1 file 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;