/*
- * Copyright (c) 2004-2009 Apple Inc. All rights reserved.
+ * Copyright (c) 2004-2015 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+#include <sys/cdefs.h>
+
#ifndef lint
-static const char copyright[] =
+__unused static const char copyright[] =
"@(#) Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000\n\
The Regents of the University of California. All rights reserved.\n";
-#if 0
-static const char rcsid[] =
- "@(#)$Id: traceroute.c,v 1.4 2006/02/07 06:22:57 lindak Exp $ (LBL)";
-#endif
-static const char rcsid[] =
- "$FreeBSD: src/contrib/traceroute/traceroute.c,v 1.35 2008/02/20 23:29:52 rpaulo Exp $";
#endif
/*
int sump = 0;
int sockerrno = 0;
+ if (argv[0] == NULL)
+ prog = "traceroute";
+ else if ((cp = strrchr(argv[0], '/')) != NULL)
+ prog = cp + 1;
+ else
+ prog = argv[0];
+
/* Insure the socket fds won't be 0, 1 or 2 */
if (open(devnull, O_RDONLY) < 0 ||
open(devnull, O_RDONLY) < 0 ||
max_ttl = 30;
#endif
- if (argv[0] == NULL)
- prog = "traceroute";
- else if ((cp = strrchr(argv[0], '/')) != NULL)
- prog = cp + 1;
- else
- prog = argv[0];
-
opterr = 0;
while ((op = getopt(argc, argv, "aA:edDFInrSvxf:g:i:M:m:P:p:q:s:t:w:z:")) != EOF)
switch (op) {
Fprintf(stderr, "%s: icmp socket: %s\n", prog, strerror(errno));
exit(1);
}
+ (void) setsockopt(s, SOL_SOCKET, SO_RECV_ANYIF, (char *)&on,
+ sizeof(on));
if (options & SO_DEBUG)
(void)setsockopt(s, SOL_SOCKET, SO_DEBUG, (char *)&on,
sizeof(on));
socklen_t fromlen = sizeof(*fromp);
nfds = howmany(sock + 1, NFDBITS);
- if ((fdsp = malloc(nfds * sizeof(fd_mask))) == NULL)
+ if ((fdsp = malloc(nfds * sizeof(fd_set))) == NULL)
err(1, "malloc");
- memset(fdsp, 0, nfds * sizeof(fd_mask));
+ memset(fdsp, 0, nfds * sizeof(fd_set));
FD_SET(sock, fdsp);
wait.tv_sec = tp->tv_sec + waittime;
domain[0] = '\0';
else {
++cp;
- (void)strncpy(domain, cp, sizeof(domain) - 1);
- domain[sizeof(domain) - 1] = '\0';
+ memmove(domain, cp, strlen(cp) + 1);
}
}
}
if ((cp = strchr(hp->h_name, '.')) != NULL &&
strcmp(cp + 1, domain) == 0)
*cp = '\0';
- (void)strncpy(line, hp->h_name, sizeof(line) - 1);
- line[sizeof(line) - 1] = '\0';
+ (void)strlcpy(line, hp->h_name, sizeof(line));
return (line);
}
}