CVS commit: src/usr.sbin/traceroute
Module Name:src Committed By: roy Date: Wed Feb 3 06:49:18 UTC 2021 Modified Files: src/usr.sbin/traceroute: Makefile Log Message: traceroute: no longer need gcc packed member warning To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/traceroute/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/traceroute/Makefile diff -u src/usr.sbin/traceroute/Makefile:1.21 src/usr.sbin/traceroute/Makefile:1.22 --- src/usr.sbin/traceroute/Makefile:1.21 Sun Sep 6 07:20:33 2020 +++ src/usr.sbin/traceroute/Makefile Wed Feb 3 06:49:18 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.21 2020/09/06 07:20:33 mrg Exp $ +# $NetBSD: Makefile,v 1.22 2021/02/03 06:49:18 roy Exp $ USE_FORT?= yes # network client @@ -30,6 +30,4 @@ SANITIZER_RENAME_SYMBOL.rump+= getifaddr AWKS= median.awk mean.awk -CWARNFLAGS.gcc+=${GCC_NO_ADDR_OF_PACKED_MEMBER} - .include
CVS commit: src/usr.sbin/traceroute
Module Name:src Committed By: maxv Date: Fri Jan 19 14:30:09 UTC 2018 Modified Files: src/usr.sbin/traceroute: traceroute.c Log Message: Fix build failure, the structure is already defined now. To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/usr.sbin/traceroute/traceroute.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/traceroute/traceroute.c diff -u src/usr.sbin/traceroute/traceroute.c:1.83 src/usr.sbin/traceroute/traceroute.c:1.84 --- src/usr.sbin/traceroute/traceroute.c:1.83 Wed Feb 17 19:57:01 2016 +++ src/usr.sbin/traceroute/traceroute.c Fri Jan 19 14:30:09 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: traceroute.c,v 1.83 2016/02/17 19:57:01 christos Exp $ */ +/* $NetBSD: traceroute.c,v 1.84 2018/01/19 14:30:09 maxv Exp $ */ /* * Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000 @@ -30,7 +30,7 @@ static const char rcsid[] = __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997,\ 1998, 1999, 2000\ The Regents of the University of California. All rights reserved."); -__RCSID("$NetBSD: traceroute.c,v 1.83 2016/02/17 19:57:01 christos Exp $"); +__RCSID("$NetBSD: traceroute.c,v 1.84 2018/01/19 14:30:09 maxv Exp $"); #endif #endif @@ -292,34 +292,13 @@ struct outdata { * * http://www.ietf.org/proceedings/01aug/I-D/draft-ietf-mpls-icmp-02.txt */ +#ifdef ICMP_EXT_OFFSET +#undef ICMP_EXT_OFFSET +#endif #define ICMP_EXT_OFFSET8 /* ICMP type, code, checksum, unused */ + \ 128 /* original datagram */ -#define ICMP_EXT_VERSION 2 -/* - * ICMP extensions, common header - */ -struct icmp_ext_cmn_hdr { -#if BYTE_ORDER == BIG_ENDIAN - unsigned char version:4; - unsigned char reserved1:4; -#else - unsigned char reserved1:4; - unsigned char version:4; -#endif - unsigned char reserved2; - unsigned short checksum; -}; - -/* - * ICMP extensions, object header - */ -struct icmp_ext_obj_hdr { -u_short length; -u_char class_num; #define MPLS_STACK_ENTRY_CLASS 1 -u_char c_type; #define MPLS_STACK_ENTRY_C_TYPE 1 -}; struct mpls_header { #if BYTE_ORDER == BIG_ENDIAN @@ -1124,7 +1103,7 @@ wait_for_reply(int sock, struct sockaddr static void decode_extensions(unsigned char *buf, int ip_len) { -struct icmp_ext_cmn_hdr *cmn_hdr; +struct icmp_ext_hdr *cmn_hdr; struct icmp_ext_obj_hdr *obj_hdr; union { struct mpls_header mpls; @@ -1136,7 +1115,7 @@ decode_extensions(unsigned char *buf, in ip = (struct ip *)buf; if (ip_len < (int)((ip->ip_hl << 2) + ICMP_EXT_OFFSET + - sizeof(struct icmp_ext_cmn_hdr))) { + sizeof(struct icmp_ext_hdr))) { /* * No support for ICMP extensions on this host */ @@ -1147,7 +1126,7 @@ decode_extensions(unsigned char *buf, in * Move forward to the start of the ICMP extensions, if present */ buf += (ip->ip_hl << 2) + ICMP_EXT_OFFSET; -cmn_hdr = (struct icmp_ext_cmn_hdr *)buf; +cmn_hdr = (struct icmp_ext_hdr *)buf; if (cmn_hdr->version != ICMP_EXT_VERSION) { /*
CVS commit: src/usr.sbin/traceroute
Module Name:src Committed By: christos Date: Wed Feb 17 19:57:01 UTC 2016 Modified Files: src/usr.sbin/traceroute: traceroute.c Log Message: PR/50821: David Binderman: remove "i <" i < To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/usr.sbin/traceroute/traceroute.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/traceroute/traceroute.c diff -u src/usr.sbin/traceroute/traceroute.c:1.82 src/usr.sbin/traceroute/traceroute.c:1.83 --- src/usr.sbin/traceroute/traceroute.c:1.82 Mon Oct 26 04:53:45 2015 +++ src/usr.sbin/traceroute/traceroute.c Wed Feb 17 14:57:01 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: traceroute.c,v 1.82 2015/10/26 08:53:45 shm Exp $ */ +/* $NetBSD: traceroute.c,v 1.83 2016/02/17 19:57:01 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000 @@ -30,7 +30,7 @@ static const char rcsid[] = __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997,\ 1998, 1999, 2000\ The Regents of the University of California. All rights reserved."); -__RCSID("$NetBSD: traceroute.c,v 1.82 2015/10/26 08:53:45 shm Exp $"); +__RCSID("$NetBSD: traceroute.c,v 1.83 2016/02/17 19:57:01 christos Exp $"); #endif #endif @@ -1244,7 +1244,7 @@ dump_packet(void) Fprintf(stderr, "packet data:"); #ifdef __hpux - for (p = useicmp ? (u_char *)outicmp : (u_char *)outudp, i = 0; i < + for (p = useicmp ? (u_char *)outicmp : (u_char *)outudp, i = 0; i < packlen - (sizeof(*outip) + optlen); i++) #else for (p = (u_char *)outip, i = 0; i < packlen; i++)
CVS commit: src/usr.sbin/traceroute
Module Name:src Committed By: shm Date: Mon Oct 26 08:53:45 UTC 2015 Modified Files: src/usr.sbin/traceroute: traceroute.c Log Message: Added missed break statement. (Missed break in -z option implicitly implies -P option) To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/usr.sbin/traceroute/traceroute.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/traceroute/traceroute.c diff -u src/usr.sbin/traceroute/traceroute.c:1.81 src/usr.sbin/traceroute/traceroute.c:1.82 --- src/usr.sbin/traceroute/traceroute.c:1.81 Thu Aug 16 00:40:28 2012 +++ src/usr.sbin/traceroute/traceroute.c Mon Oct 26 08:53:45 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: traceroute.c,v 1.81 2012/08/16 00:40:28 zafer Exp $ */ +/* $NetBSD: traceroute.c,v 1.82 2015/10/26 08:53:45 shm Exp $ */ /* * Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000 @@ -30,7 +30,7 @@ static const char rcsid[] = __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997,\ 1998, 1999, 2000\ The Regents of the University of California. All rights reserved."); -__RCSID("$NetBSD: traceroute.c,v 1.81 2012/08/16 00:40:28 zafer Exp $"); +__RCSID("$NetBSD: traceroute.c,v 1.82 2015/10/26 08:53:45 shm Exp $"); #endif #endif @@ -607,6 +607,7 @@ main(int argc, char **argv) case 'z': pausemsecs = str2val(optarg, "pause msecs", 0, 60 * 60 * 1000); + break; case 'P': off = IP_DF;
CVS commit: src/usr.sbin/traceroute
Module Name:src Committed By: zafer Date: Thu Aug 16 00:40:29 UTC 2012 Modified Files: src/usr.sbin/traceroute: traceroute.c Log Message: Pretty print multipath routes. From FreeBSD. ok christos@ To generate a diff of this commit: cvs rdiff -u -r1.80 -r1.81 src/usr.sbin/traceroute/traceroute.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/traceroute/traceroute.c diff -u src/usr.sbin/traceroute/traceroute.c:1.80 src/usr.sbin/traceroute/traceroute.c:1.81 --- src/usr.sbin/traceroute/traceroute.c:1.80 Wed Jan 4 16:09:44 2012 +++ src/usr.sbin/traceroute/traceroute.c Thu Aug 16 00:40:28 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: traceroute.c,v 1.80 2012/01/04 16:09:44 drochner Exp $ */ +/* $NetBSD: traceroute.c,v 1.81 2012/08/16 00:40:28 zafer Exp $ */ /* * Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000 @@ -30,7 +30,7 @@ static const char rcsid[] = __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997,\ 1998, 1999, 2000\ The Regents of the University of California. All rights reserved."); -__RCSID("$NetBSD: traceroute.c,v 1.80 2012/01/04 16:09:44 drochner Exp $"); +__RCSID("$NetBSD: traceroute.c,v 1.81 2012/08/16 00:40:28 zafer Exp $"); #endif #endif @@ -984,6 +984,7 @@ again: continue; if (!gotlastaddr || from->sin_addr.s_addr != lastaddr) { + if (gotlastaddr) printf("\n "); print(packet, cc, from); lastaddr = from->sin_addr.s_addr; ++gotlastaddr;
CVS commit: src/usr.sbin/traceroute
Module Name:src Committed By: christos Date: Sun Sep 11 01:06:26 UTC 2011 Modified Files: src/usr.sbin/traceroute: CHANGES Makefile ifaddrlist.c traceroute.8 traceroute.c version.c Log Message: merge in traceroute1.4a12. Our sources are so different that it is really difficult to do this with an import. To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 src/usr.sbin/traceroute/CHANGES cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/traceroute/Makefile cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/traceroute/ifaddrlist.c cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/traceroute/traceroute.8 cvs rdiff -u -r1.78 -r1.79 src/usr.sbin/traceroute/traceroute.c cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/traceroute/version.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/traceroute/CHANGES diff -u src/usr.sbin/traceroute/CHANGES:1.1.1.1 src/usr.sbin/traceroute/CHANGES:1.2 --- src/usr.sbin/traceroute/CHANGES:1.1.1.1 Fri Oct 3 18:25:19 1997 +++ src/usr.sbin/traceroute/CHANGES Sat Sep 10 21:06:26 2011 @@ -1,7 +1,7 @@ -$NetBSD: CHANGES,v 1.1.1.1 1997/10/03 22:25:19 christos Exp $ -@(#) Header: CHANGES,v 1.17 97/06/13 02:27:02 leres Exp (LBL) +$NetBSD: CHANGES,v 1.2 2011/09/11 01:06:26 christos Exp $ +@(#) Id: CHANGES,v 1.23 2000/12/14 06:53:11 leres Exp (LBL) -v1.4 Fri Jun 13 02:23:51 PDT 1997 +v1.4 Wed Dec 13 22:50:35 PST 2000 - Add an option to use icmp echo instead of udp datagrams. @@ -12,8 +12,6 @@ - Added flags to set the first ttl and to set the don't fragment bit. -- Removed dependence on strdup(). - - Add a local autoconf macro to check for routines in libraries; the autoconf version is broken (it only puts the library name in the cache variable name). Thanks to John Hawkinson. @@ -21,6 +19,70 @@ - Add a local autoconf macro to check for types; the autoconf version is broken (it uses grep instead of actually compiling a code fragment). +- Attempt to detect "egcs" versions of gcc. + +- Fix problems caused by savestr(). + +- Detect when there are more interfaces than we can deal with. Thanks + to Guy Harris g...@netapp.com. + +- Accommodate changes made to FreeBSD 3.2-RELEASE network headers files. + +- The ip header offset needs to be byte swapped under Solaris on the + intel as well. Reported by John McDermott (j...@jkintl.com) Also byte + ip length and offset for linux. + +- In wait_for_reply(), use passed socket instead of global one. Thanks + to Richard Kettlewell (richard.kettlew...@kewill.com) + +- Check for IFF_LOOPBACK as a define or an enum (concession to linux). + Reported by Robert Bihlmeyer (ro...@orcus.priv.at) + +- Increase size of SIOCGIFCONF buffer to accommodate systems with lots + of virtual interfaces. Ignore sun virtual interfaces. Suggested by + Ian Donaldson (i...@aone.com.au) + +- Always calculate icmp checksums when using -I. Reported by Soumen + (sbis...@novell.com) + +- Documentation fix for description of -p. Thanks to Jeffrey C Honig + (j...@bsdi.com) + +- Enable ip checksums for Solaris 2.6 and higher (since they seem to + work correctly now). + +- Avoid problems when broken routers return 0.0.0.0 as their source + address. Thanks to John Hawkinson (jh...@bbnplanet.com) + +- Canonicalize hostname if gethostname() doesn't return a domain. + +- Add -z flag (pause msecs) to allow optional pause between probes. + Suggested by Dave Morrison (drmor...@uplanet.com) + +- Fix max packet length test. + +- Use "/dev/null" instead of "." for file descriptor fodder. + Suggested by Tim Robbins (f...@box3n.gumbynet.org) + +- Watch for a NULL argv[0]. Suggested by Tim Robbins. + +- Be careful with hostname legnths. + +- Print RFC1191 Path MTU Discovery value on "needfrag" unreachables. + +- Limit port size to 16 bits. Suggested by Tim Robbins. + +- Limit wait time to 24 hours. + +- Modified linux specific struct ipovly definition to avoid problems + with 64 bit systems. Problem reported by Uros Prestor + (u...@turbolinux.com) + +- Use kernel routing tables to determine correct source address. + Three styles are supported: bsd/socket, solaris/mib and linux. + +- Fix configure to recognize older versions of Solaris. + v1.3.2 Thu Sep 26 18:06:16 PDT 1996 - Rewrite source routing code to eliminate a number of problems on Index: src/usr.sbin/traceroute/Makefile diff -u src/usr.sbin/traceroute/Makefile:1.18 src/usr.sbin/traceroute/Makefile:1.19 --- src/usr.sbin/traceroute/Makefile:1.18 Mon May 9 21:52:49 2011 +++ src/usr.sbin/traceroute/Makefile Sat Sep 10 21:06:26 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.18 2011/05/10 01:52:49 christos Exp $ +# $NetBSD: Makefile,v 1.19 2011/09/11 01:06:26 christos Exp $ USE_FORT?= yes # network client @@ -8,6 +8,7 @@ CPPFLAGS+=-DHAVE_MALLOC_H=1 -DHAVE_SYS_SELECT_H=1 -DHAVE_SYS_SOCKIO_H=1 CPPFLAGS+=-DHAVE_STRERROR=1 -DHAVE_SETLINEBUF=1 -DHAVE_SOCKADDR_SA_LEN=1 CPPFLAGS+=-DHAVE_RAW
CVS commit: src/usr.sbin/traceroute
Module Name:src Committed By: christos Date: Thu May 12 01:59:16 UTC 2011 Modified Files: src/usr.sbin/traceroute: traceroute.c Log Message: use err(3) and warn(3) for error and warning printing, tiny knf. To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/usr.sbin/traceroute/traceroute.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/traceroute/traceroute.c diff -u src/usr.sbin/traceroute/traceroute.c:1.77 src/usr.sbin/traceroute/traceroute.c:1.78 --- src/usr.sbin/traceroute/traceroute.c:1.77 Mon May 9 21:52:49 2011 +++ src/usr.sbin/traceroute/traceroute.c Wed May 11 21:59:16 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: traceroute.c,v 1.77 2011/05/10 01:52:49 christos Exp $ */ +/* $NetBSD: traceroute.c,v 1.78 2011/05/12 01:59:16 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997 @@ -29,7 +29,7 @@ #else __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997\ The Regents of the University of California. All rights reserved."); -__RCSID("$NetBSD: traceroute.c,v 1.77 2011/05/10 01:52:49 christos Exp $"); +__RCSID("$NetBSD: traceroute.c,v 1.78 2011/05/12 01:59:16 christos Exp $"); #endif #endif @@ -453,10 +453,8 @@ if (prog_init && prog_init() == -1) err(1, "init failed"); - if ((s = prog_socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) { - Fprintf(stderr, "%s: icmp socket: %s\n", prog, strerror(errno)); - exit(1); - } + if ((s = prog_socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) + err(1, "icmp socket"); /* * XXX 'useicmp' will always be zero here. I think the HP-UX users @@ -468,10 +466,8 @@ sndsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW useicmp ? IPPROTO_ICMP : IPPROTO_UDP); #endif - if (sndsock < 0) { - Fprintf(stderr, "%s: raw socket: %s\n", prog, strerror(errno)); - exit(1); - } + if (sndsock < 0) + err(1, "raw socket"); /* Revert to non-privileged user after opening sockets */ setuid(getuid()); @@ -509,12 +505,8 @@ break; case 'g': - if (lsrr >= NGATEWAYS) { -Fprintf(stderr, -"%s: No more than %d gateways\n", -prog, NGATEWAYS); -exit(1); - } + if (lsrr >= NGATEWAYS) +errx(1, "more than %d gateways", NGATEWAYS); getaddr(gwlist + lsrr, optarg); ++lsrr; break; @@ -589,15 +581,12 @@ usage(); } - if (first_ttl > max_ttl) { - Fprintf(stderr, - "%s: first ttl (%d) may not be greater than max ttl (%d)\n", - prog, first_ttl, max_ttl); - exit(1); - } + if (first_ttl > max_ttl) + errx(1, "first ttl (%d) may not be greater than max ttl (%d)", + first_ttl, max_ttl); if (!docksum) - Fprintf(stderr, "%s: Warning: ckecksums disabled\n", prog); + warnx("ckecksums disabled"); if (lsrr > 0) optlen = (lsrr + 1) * sizeof(gwlist[0]); @@ -608,11 +597,9 @@ minpacket += sizeof(*outudp); if (packlen == 0) packlen = minpacket; /* minimum sized packet */ - else if (minpacket > packlen || packlen > maxpacket) { - Fprintf(stderr, "%s: packet size must be %d <= s <= %d\n", - prog, minpacket, maxpacket); - exit(1); - } + else if (minpacket > packlen || packlen > maxpacket) + errx(1, "packet size must be %d <= s <= %d", + minpacket, maxpacket); if (mtudisc) packlen = *mtuptr++; @@ -630,9 +617,8 @@ hi = gethostinfo(hostname); setsin(to, hi->addrs[0]); if (hi->n > 1) - Fprintf(stderr, - "%s: Warning: %s has multiple addresses; using %s\n", -prog, hostname, inet_ntoa(to->sin_addr)); + warnx("%s has multiple addresses; using %s", + hostname, inet_ntoa(to->sin_addr)); hostname = hi->name; hi->name = NULL; freehostinfo(hi); @@ -648,12 +634,10 @@ setvbuf(stdout, NULL, _IOLBF, 0); #endif - outip = (struct ip *)malloc((unsigned)packlen); - if (outip == NULL) { - Fprintf(stderr, "%s: malloc: %s\n", prog, strerror(errno)); - exit(1); - } - memset((char *)outip, 0, packlen); + outip = malloc((unsigned)packlen); + if (outip == NULL) + err(1, "malloc"); + memset(outip, 0, packlen); outip->ip_v = IPVERSION; if (settos) @@ -798,67 +782,51 @@ memcpy(optlist + 4, gwlist, i); if ((prog_setsockopt(sndsock, IPPROTO_IP, IP_OPTIONS, optlist, - i + sizeof(gwlist[0]))) < 0) { - Fprintf(stderr, "%s: IP_OPTIONS: %s\n", - prog, strerror(errno)); - exit(1); - } + i + sizeof(gwlist[0]))) < 0) + err(1, "IP_OPTIONS"); } #endif #ifdef SO_SNDBUF if (prog_setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, (char *)&packlen, - sizeof(packlen)) < 0) { - Fprintf(stderr, "%s: SO_SNDBUF: %s\n", prog, strerror(errno)); - exit(1); - } + sizeof(packlen)) < 0) + err(1, "SO_SNDBUF"); #endif #ifdef IP_HDRINCL if (prog_setsockopt(sndsock, IPPROTO_IP, IP_HDRINCL, (char *)&on, - sizeof(on)) < 0) { - Fprintf(stderr, "%s: IP_HDRINCL: %s\n", prog, strerror(errno)); - exit(1); - } + sizeof(on)) < 0) + err(1, "IP_HDRINCL"); #else #if
CVS commit: src/usr.sbin/traceroute
Module Name:src Committed By: christos Date: Wed May 11 00:38:28 UTC 2011 Modified Files: src/usr.sbin/traceroute: ifaddrlist.c ifaddrlist.h Log Message: Don't use a static buffer for ifaddrs (and not check for overflowing it!) (speciallly if you are setuid!) To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/traceroute/ifaddrlist.c cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/traceroute/ifaddrlist.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/traceroute/ifaddrlist.c diff -u src/usr.sbin/traceroute/ifaddrlist.c:1.8 src/usr.sbin/traceroute/ifaddrlist.c:1.9 --- src/usr.sbin/traceroute/ifaddrlist.c:1.8 Mon May 9 21:52:49 2011 +++ src/usr.sbin/traceroute/ifaddrlist.c Tue May 10 20:38:28 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ifaddrlist.c,v 1.8 2011/05/10 01:52:49 christos Exp $ */ +/* $NetBSD: ifaddrlist.c,v 1.9 2011/05/11 00:38:28 christos Exp $ */ /* * Copyright (c) 1997 @@ -39,7 +39,7 @@ static const char rcsid[] = "@(#) Header: ifaddrlist.c,v 1.2 97/04/22 13:31:05 leres Exp (LBL)"; #else -__RCSID("$NetBSD: ifaddrlist.c,v 1.8 2011/05/10 01:52:49 christos Exp $"); +__RCSID("$NetBSD: ifaddrlist.c,v 1.9 2011/05/11 00:38:28 christos Exp $"); #endif #endif @@ -82,29 +82,23 @@ #define ISLOOPBACK(p) (strcmp((p)->ifa_name, "lo0") == 0) #endif -#define MAX_IPADDR 256 - /* * Return the interface list */ -int -ifaddrlist(struct ifaddrlist **ipaddrp, char *errbuf, int buflen) +ssize_t +ifaddrlist(struct ifaddrlist **ipaddrp, char *errbuf, size_t buflen) { - int nipaddr; struct sockaddr_in *sin; - struct ifaddrs *ifap, *ifa; - struct ifaddrlist *al; - static struct ifaddrlist xifaddrlist[MAX_IPADDR]; - - al = xifaddrlist; - nipaddr = 0; - - if (getifaddrs(&ifap) != 0) { - (void)snprintf(errbuf, buflen, "getifaddrs: %s", - strerror(errno)); - return (-1); - } - + struct ifaddrs *ifap = NULL, *ifa; + struct ifaddrlist *al = NULL, *nal; + size_t i = 0, maxal = 10; + + if (getifaddrs(&ifap) != 0) + goto out; + + if ((al = malloc(maxal * sizeof(*al))) == NULL) + goto out; + for (ifa = ifap; ifa; ifa = ifa->ifa_next) { if (ifa->ifa_addr->sa_family != AF_INET) continue; @@ -121,12 +115,31 @@ if (ntohl(sin->sin_addr.s_addr) == INADDR_LOOPBACK) continue; - al->addr = sin->sin_addr.s_addr; - al->device = strdup(ifa->ifa_name); - ++al; - ++nipaddr; + if (i == maxal) { + maxal <<= 1; + if ((nal = realloc(al, maxal * sizeof(*al))) == NULL) +goto out; + al = nal; + } + + al[i].addr = sin->sin_addr.s_addr; + if ((al[i].device = strdup(ifa->ifa_name)) == NULL) + goto out; + i++; } - *ipaddrp = xifaddrlist; + if ((nal = realloc(al, i * sizeof(*al))) == NULL) + goto out; freeifaddrs(ifap); - return (nipaddr); + *ipaddrp = nal; + return (ssize_t)i; +out: + if (ifap) + freeifaddrs(ifap); + if (al) { + while (i > 0) + free(al[--i].device); + free(al); + } + (void)snprintf(errbuf, buflen, "%s: %s", __func__, strerror(errno)); + return -1; } Index: src/usr.sbin/traceroute/ifaddrlist.h diff -u src/usr.sbin/traceroute/ifaddrlist.h:1.2 src/usr.sbin/traceroute/ifaddrlist.h:1.3 --- src/usr.sbin/traceroute/ifaddrlist.h:1.2 Sat Jul 4 16:47:24 1998 +++ src/usr.sbin/traceroute/ifaddrlist.h Tue May 10 20:38:28 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ifaddrlist.h,v 1.2 1998/07/04 20:47:24 mrg Exp $ */ +/* $NetBSD: ifaddrlist.h,v 1.3 2011/05/11 00:38:28 christos Exp $ */ /* * Copyright (c) 1997 @@ -24,8 +24,8 @@ */ struct ifaddrlist { - u_int32_t addr; + uint32_t addr; char *device; }; -int ifaddrlist(struct ifaddrlist **, char *, int); +ssize_t ifaddrlist(struct ifaddrlist **, char *, size_t);
CVS commit: src/usr.sbin/traceroute
Module Name:src Committed By: wiz Date: Tue Jan 4 10:26:56 UTC 2011 Modified Files: src/usr.sbin/traceroute: as.c Log Message: Fix possible NULL pointer dereference in #ifdef AS_DEBUG_FILE. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/traceroute/as.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/traceroute/as.c diff -u src/usr.sbin/traceroute/as.c:1.2 src/usr.sbin/traceroute/as.c:1.3 --- src/usr.sbin/traceroute/as.c:1.2 Mon Apr 28 20:24:17 2008 +++ src/usr.sbin/traceroute/as.c Tue Jan 4 10:26:56 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: as.c,v 1.2 2008/04/28 20:24:17 martin Exp $ */ +/* $NetBSD: as.c,v 1.3 2011/01/04 10:26:56 wiz Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -119,10 +119,12 @@ asn->as_f = f; #ifdef AS_DEBUG_FILE - asn->as_debug = fopen(AS_DEBUG_FILE, "w"); - if (asn->as_debug) { - (void)fprintf(asn->as_debug, ">> !!\n"); - (void)fflush(asn->as_debug); + if (asn) { + asn->as_debug = fopen(AS_DEBUG_FILE, "w"); + if (asn->as_debug) { + (void)fprintf(asn->as_debug, ">> !!\n"); + (void)fflush(asn->as_debug); + } } #endif /* AS_DEBUG_FILE */
CVS commit: src/usr.sbin/traceroute
Module Name:src Committed By: pooka Date: Wed Dec 15 00:09:42 UTC 2010 Modified Files: src/usr.sbin/traceroute: Makefile traceroute.c Added Files: src/usr.sbin/traceroute: prog_ops.h traceroute_hostops.c traceroute_rumpops.c Log Message: Use RUMPPRG. I think it's safe to say there's not going to be a new upstream version of traceroute to import. AS# lookup is still done using host networking. Rationale: the relevance to where that data comes from with respect to network tracing is zero (be it socket, local file, db, whatever). To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/traceroute/Makefile cvs rdiff -u -r0 -r1.1 src/usr.sbin/traceroute/prog_ops.h \ src/usr.sbin/traceroute/traceroute_hostops.c \ src/usr.sbin/traceroute/traceroute_rumpops.c cvs rdiff -u -r1.75 -r1.76 src/usr.sbin/traceroute/traceroute.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/traceroute/Makefile diff -u src/usr.sbin/traceroute/Makefile:1.16 src/usr.sbin/traceroute/Makefile:1.17 --- src/usr.sbin/traceroute/Makefile:1.16 Wed Apr 22 15:23:09 2009 +++ src/usr.sbin/traceroute/Makefile Wed Dec 15 00:09:41 2010 @@ -1,10 +1,10 @@ -# $NetBSD: Makefile,v 1.16 2009/04/22 15:23:09 lukem Exp $ +# $NetBSD: Makefile,v 1.17 2010/12/15 00:09:41 pooka Exp $ WARNS?= 1 # XXX: out of date third-party program USE_FORT?= yes # network client -PROG= traceroute +RUMPPRG=traceroute MAN= traceroute.8 CPPFLAGS+=-DHAVE_MALLOC_H=1 -DHAVE_SYS_SELECT_H=1 -DHAVE_SYS_SOCKIO_H=1 @@ -21,6 +21,10 @@ SRCS= traceroute.c ifaddrlist.c SRCS+= version.c as.c +.PATH: ${.CURDIR}/../../lib/libc/net +RUMPSRCS= getifaddrs.c +CPPFLAGS+= -DRUMP_ACTION + AWKS= median.awk mean.awk .include Index: src/usr.sbin/traceroute/traceroute.c diff -u src/usr.sbin/traceroute/traceroute.c:1.75 src/usr.sbin/traceroute/traceroute.c:1.76 --- src/usr.sbin/traceroute/traceroute.c:1.75 Fri Jul 2 12:13:11 2010 +++ src/usr.sbin/traceroute/traceroute.c Wed Dec 15 00:09:41 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: traceroute.c,v 1.75 2010/07/02 12:13:11 kefren Exp $ */ +/* $NetBSD: traceroute.c,v 1.76 2010/12/15 00:09:41 pooka Exp $ */ /* * Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997 @@ -29,7 +29,7 @@ #else __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997\ The Regents of the University of California. All rights reserved."); -__RCSID("$NetBSD: traceroute.c,v 1.75 2010/07/02 12:13:11 kefren Exp $"); +__RCSID("$NetBSD: traceroute.c,v 1.76 2010/12/15 00:09:41 pooka Exp $"); #endif #endif @@ -222,6 +222,7 @@ #include #include +#include #include #ifdef HAVE_MALLOC_H #include @@ -245,6 +246,7 @@ #include "ifaddrlist.h" #include "as.h" +#include "prog_ops.h" /* Maximum number of gateways (include room for one noop) */ #define NGATEWAYS ((int)((MAX_IPOPTLEN - IPOPT_MINOFF - 1) / sizeof(u_int32_t))) @@ -453,7 +455,10 @@ setprogname(argv[0]); prog = getprogname(); - if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) { + if (prog_init && prog_init() == -1) + err(1, "init failed"); + + if ((s = prog_socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) { Fprintf(stderr, "%s: icmp socket: %s\n", prog, strerror(errno)); exit(1); } @@ -463,7 +468,7 @@ * running our traceroute code will forgive us. */ #ifndef __hpux - sndsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW); + sndsock = prog_socket(AF_INET, SOCK_RAW, IPPROTO_RAW); #else sndsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW useicmp ? IPPROTO_ICMP : IPPROTO_UDP); @@ -476,7 +481,7 @@ /* Revert to non-privileged user after opening sockets */ setuid(getuid()); - (void) sysctl(mib, sizeof(mib)/sizeof(mib[0]), &max_ttl, &size, + (void) prog_sysctl(mib, sizeof(mib)/sizeof(mib[0]), &max_ttl, &size, NULL, 0); opterr = 0; @@ -711,7 +716,7 @@ } if (options & SO_DEBUG) - (void)setsockopt(s, SOL_SOCKET, SO_DEBUG, (char *)&on, + (void)prog_setsockopt(s, SOL_SOCKET, SO_DEBUG, (char *)&on, sizeof(on)); #ifdef IPSEC #ifdef IPSEC_POLICY_IPSEC @@ -727,19 +732,19 @@ { int level = IPSEC_LEVEL_AVAIL; - (void)setsockopt(s, IPPROTO_IP, IP_ESP_TRANS_LEVEL, &level, + (void)prog_setsockopt(s, IPPROTO_IP, IP_ESP_TRANS_LEVEL, &level, sizeof(level)); - (void)setsockopt(s, IPPROTO_IP, IP_ESP_NETWORK_LEVEL, &level, + (void)prog_setsockopt(s, IPPROTO_IP, IP_ESP_NETWORK_LEVEL, &level, sizeof(level)); #ifdef IP_AUTH_TRANS_LEVEL - (void)setsockopt(s, IPPROTO_IP, IP_AUTH_TRANS_LEVEL, &level, + (void)prog_setsockopt(s, IPPROTO_IP, IP_AUTH_TRANS_LEVEL, &level, sizeof(level)); #else - (void)setsockopt(s, IPPROTO_IP, IP_AUTH_LEVEL, &level, + (void)prog_setsockopt(s, IPPROTO_IP, IP_AUTH_LEVEL, &level, sizeof(level)); #endif #ifdef IP_AUTH_NETWORK_LEVEL - (void)setsockopt(s, IPPROTO_IP, IP_AUTH_NETWORK_LEVEL, &level, + (void)prog_setsockopt(s, IPPROTO_I
CVS commit: src/usr.sbin/traceroute
Module Name:src Committed By: kefren Date: Fri Jul 2 12:13:11 UTC 2010 Modified Files: src/usr.sbin/traceroute: traceroute.c Log Message: Fix incomplete extensions sanity checks To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/usr.sbin/traceroute/traceroute.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/traceroute/traceroute.c diff -u src/usr.sbin/traceroute/traceroute.c:1.74 src/usr.sbin/traceroute/traceroute.c:1.75 --- src/usr.sbin/traceroute/traceroute.c:1.74 Mon Jul 21 13:37:00 2008 +++ src/usr.sbin/traceroute/traceroute.c Fri Jul 2 12:13:11 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: traceroute.c,v 1.74 2008/07/21 13:37:00 lukem Exp $ */ +/* $NetBSD: traceroute.c,v 1.75 2010/07/02 12:13:11 kefren Exp $ */ /* * Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997 @@ -29,7 +29,7 @@ #else __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997\ The Regents of the University of California. All rights reserved."); -__RCSID("$NetBSD: traceroute.c,v 1.74 2008/07/21 13:37:00 lukem Exp $"); +__RCSID("$NetBSD: traceroute.c,v 1.75 2010/07/02 12:13:11 kefren Exp $"); #endif #endif @@ -1128,7 +1128,8 @@ ip = (struct ip *)buf; -if (ip_len <= sizeof(struct ip) + ICMP_EXT_OFFSET) { +if (ip_len < (ip->ip_hl << 2) + ICMP_EXT_OFFSET + + sizeof(struct icmp_ext_cmn_hdr)) { /* * No support for ICMP extensions on this host */ @@ -1166,16 +1167,15 @@ buf += sizeof(*cmn_hdr); datalen -= sizeof(*cmn_hdr); -while (datalen > 0) { +while (datalen >= sizeof(struct icmp_ext_obj_hdr)) { obj_hdr = (struct icmp_ext_obj_hdr *)buf; obj_len = ntohs(obj_hdr->length); /* * Sanity check the length field */ - if (obj_len > datalen) { + if (obj_len > datalen) return; - } datalen -= obj_len;
CVS commit: src/usr.sbin/traceroute
Module Name:src Committed By: dholland Date: Sun May 30 00:52:06 UTC 2010 Removed Files: src/usr.sbin/traceroute: README Log Message: with luck this is the last one To generate a diff of this commit: cvs rdiff -u -r1.1.1.4 -r0 src/usr.sbin/traceroute/README Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.