From: brad Date: Fri, 10 Jan 2014 06:18:40 +0000 (+0000) Subject: Fix a bug found in ping6 when rebuilding with stack protector strong. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=048aea0f975b403c23516f2af66cbf13174a7553;p=openbsd Fix a bug found in ping6 when rebuilding with stack protector strong. rtableid is unitialized; the stack protector strong binary would fail to set the routing table id. Copy the rtableid initialization over to ping to keep what is essentially similar code in sync. ok deraadt@ --- diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index e7f57ecb96e..2cc843ed556 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping.c,v 1.97 2013/11/22 04:12:48 deraadt Exp $ */ +/* $OpenBSD: ping.c,v 1.98 2014/01/10 06:18:40 brad Exp $ */ /* $NetBSD: ping.c,v 1.20 1995/08/11 22:37:58 cgd Exp $ */ /* @@ -190,7 +190,7 @@ main(int argc, char *argv[]) fd_set *fdmaskp; size_t fdmasks; uid_t uid; - u_int rtableid; + int rtableid = -1; if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) err(1, "socket"); diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index 970f78742c3..2ac9440d057 100644 --- a/sbin/ping6/ping6.c +++ b/sbin/ping6/ping6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping6.c,v 1.86 2013/11/22 04:12:48 deraadt Exp $ */ +/* $OpenBSD: ping6.c,v 1.87 2014/01/10 06:18:40 brad Exp $ */ /* $KAME: ping6.c,v 1.163 2002/10/25 02:19:06 itojun Exp $ */ /* @@ -271,7 +271,7 @@ main(int argc, char *argv[]) size_t rthlen; int mflag = 0; uid_t uid; - u_int rtableid; + int rtableid = -1; /* just to be sure */ memset(&smsghdr, 0, sizeof(smsghdr)); @@ -544,8 +544,8 @@ main(int argc, char *argv[]) res->ai_protocol)) < 0) err(1, "socket"); - if (setsockopt(s, SOL_SOCKET, SO_RTABLE, &rtableid, - sizeof(rtableid)) == -1) + if (rtableid >= 0 && (setsockopt(s, SOL_SOCKET, SO_RTABLE, &rtableid, + sizeof(rtableid)) == -1)) err(1, "setsockopt SO_RTABLE"); /* set the source address if specified. */