summaryrefslogtreecommitdiff
path: root/usr.sbin/traceroute
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2014-04-23 09:10:54 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2014-04-23 09:10:54 +0000
commit83a6e338928cd40c00c59cf54588be04da926729 (patch)
treeb71270cc22bc70cb39b42d433a1458c1233cd7b1 /usr.sbin/traceroute
parent0707b727131a239f2173f8474daed8d4d38b7257 (diff)
Add error checking to sysctl. While there pass in an int otherwise
it failes with ENOMEM in traceroute. OK benno@
Diffstat (limited to 'usr.sbin/traceroute')
-rw-r--r--usr.sbin/traceroute/traceroute.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c
index fd023ef45ed..441d8fe2a8d 100644
--- a/usr.sbin/traceroute/traceroute.c
+++ b/usr.sbin/traceroute/traceroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: traceroute.c,v 1.117 2014/04/23 08:58:26 florian Exp $ */
+/* $OpenBSD: traceroute.c,v 1.118 2014/04/23 09:10:53 florian Exp $ */
/* $NetBSD: traceroute.c,v 1.10 1995/05/21 15:50:45 mycroft Exp $ */
/*-
@@ -315,7 +315,7 @@ main(int argc, char *argv[])
int ch, i, lsrr = 0, on = 1, probe, seq = 0, tos = 0, error;
int last_tos = 0, tos_returned;
struct addrinfo hints, *res;
- size_t size = sizeof(max_ttl);
+ size_t size;
struct sockaddr_in from4, to4;
struct sockaddr *from, *to;
struct hostent *hp;
@@ -339,8 +339,10 @@ main(int argc, char *argv[])
if (setresuid(uid, uid, uid) == -1)
err(1, "setresuid");
- (void) sysctl(mib, sizeof(mib)/sizeof(mib[0]), &max_ttl, &size,
- NULL, 0);
+ size = sizeof(i);
+ if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), &i, &size, NULL, 0) == -1)
+ err(1, "sysctl");
+ max_ttl = i;
while ((ch = getopt(argc, argv, "AcDdf:g:Ilm:nP:p:q:Ss:t:V:vw:x"))
!= -1)