summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorBrad Smith <brad@cvs.openbsd.org>2014-01-10 06:18:41 +0000
committerBrad Smith <brad@cvs.openbsd.org>2014-01-10 06:18:41 +0000
commit0358c6c0bc3b1157fac3e38ac389d99a7269fc8d (patch)
tree1bda52df41dcd82c26746330b545f5aad000e6e3 /sbin
parentb8f9eacab0d988a19f1d1d105509a403f2e2f050 (diff)
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@
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ping/ping.c4
-rw-r--r--sbin/ping6/ping6.c8
2 files changed, 6 insertions, 6 deletions
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. */