net-analyzer/traceroute-nanog-6.3.10-r1 prints out stack-cruft when using the -O flag. This is because the function dordata returns a local variables. Patch attached to make the local variable static fixing the bug. emerge info: Gentoo Base System version 1.12.4 Portage 2.1-r2 (default-linux/amd64/2006.0, gcc-3.4.6, glibc-2.3.6-r4, 2.6.17-gentoo-r4 x86_64) ================================================================= System uname: 2.6.17-gentoo-r4 x86_64 unknown app-admin/eselect-compiler: [Not Present] dev-lang/python: 2.4.3-r1 dev-python/pycrypto: 2.0.1-r5 dev-util/ccache: [Not Present] dev-util/confcache: [Not Present] sys-apps/sandbox: 1.2.17 sys-devel/autoconf: 2.13, 2.59-r7 sys-devel/automake: 1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2 sys-devel/binutils: 2.16.1-r3 sys-devel/gcc-config: 1.3.13-r3 sys-devel/libtool: 1.5.22 virtual/os-headers: 2.6.11-r2 ACCEPT_KEYWORDS="amd64" AUTOCLEAN="yes" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-O2 -pipe" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/share/X11/xkb" CONFIG_PROTECT_MASK="/etc/env.d /etc/gconf /etc/revdep-rebuild /etc/terminfo" CXXFLAGS="-O2 -pipe" DISTDIR="/usr/portage/distfiles" FEATURES="autoconfig distlocks metadata-transfer sandbox sfperms strict" GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo" PKGDIR="/usr/portage/packages" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" SYNC="rsync://rsync.gentoo.org/gentoo-portage" USE="amd64 X alsa avi berkdb bitmap-fonts cli crypt cups dlloader dri eds emboss encode foomaticdb fortran gif gnome gpm gstreamer gtk gtk2 imlib ipv6 isdnlog jpeg kde lzw lzw-tiff mp3 mpeg ncurses nls nptl opengl pam pcre pdflib perl png pppd python qt3 qt4 quicktime readline reflection sdl session spell spl ssl tcpd tiff truetype-fonts type1-fonts usb xorg xpm xv zlib elibc_glibc input_devices_keyboard input_devices_mouse input_devices_evdev kernel_linux userland_GNU" Unset: CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS, MAKEOPTS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY
Created attachment 94268 [details, diff] traceroute-nanog-6.3.10.patch This patch fixes dordata.
Doesn't look amd64-specific...
Hello, Would you mind giving an example? I tested the -O switch and saw no effect. Cheers, Marcelo
Hmm I can't seem to reproduce it with the current gcc, but the function dordata still returns a pointer to a char array which is created on the stack. This char array should be made static.
ebuild: src_compile() { $(tc-getCC) traceroute.c -o ${PN} ${CFLAGS} -lresolv -lm || die "Compile failed" } 19:59:25 (18.96 KB/s) - `/usr/portage/distfiles/traceroute-nanog_6.3.10-2.diff.gz' saved [16699] * checking ebuild checksums ;-) ... [ ok ] * checking auxfile checksums ;-) ... [ ok ] * checking miscfile checksums ;-) ... [ ok ] * checking traceroute-nanog_6.3.10.orig.tar.gz ;-) ... [ ok ] * checking traceroute-nanog_6.3.10-2.diff.gz ;-) ... [ ok ] >>> Unpacking source... >>> Unpacking traceroute-nanog_6.3.10.orig.tar.gz to /var/tmp/portage/net-analyzer/traceroute-nanog-6.3.10-r1/work >>> Unpacking traceroute-nanog_6.3.10-2.diff.gz to /var/tmp/portage/net-analyzer/traceroute-nanog-6.3.10-r1/work * Applying traceroute-nanog_6.3.10-2.diff ... [ ok ] >>> Source unpacked. >>> Compiling source in /var/tmp/portage/net-analyzer/traceroute-nanog-6.3.10-r1/work/traceroute-nanog-6.3.10.orig ... traceroute.c: In function 'main': traceroute.c:1180: warning: incompatible implicit declaration of built-in function 'strncpy' traceroute.c:1209: warning: incompatible implicit declaration of built-in function 'strncpy' traceroute.c: In function 'print_from': traceroute.c:2322: warning: incompatible implicit declaration of built-in function 'memcpy' traceroute.c: In function 'inetname': traceroute.c:2393: warning: incompatible implicit declaration of built-in function 'strcpy' traceroute.c:2408: warning: incompatible implicit declaration of built-in function 'strncpy' traceroute.c: In function 'lookup_owner': traceroute.c:2468: warning: incompatible implicit declaration of built-in function 'strchr' traceroute.c:2472: warning: incompatible implicit declaration of built-in function 'strlen' traceroute.c: In function 'get_origin': traceroute.c:2646: warning: incompatible implicit declaration of built-in function 'strcpy' traceroute.c:2648: warning: incompatible implicit declaration of built-in function 'strncpy' traceroute.c:2674: warning: incompatible implicit declaration of built-in function 'strcpy' traceroute.c:2676: warning: incompatible implicit declaration of built-in function 'strncpy' traceroute.c:2711: warning: incompatible implicit declaration of built-in function 'strlen' traceroute.c:2719: warning: incompatible implicit declaration of built-in function 'strcpy' traceroute.c:2744: warning: incompatible implicit declaration of built-in function 'strcpy' traceroute.c:2746: warning: incompatible implicit declaration of built-in functi on 'strncpy' traceroute.c:2753: warning: incompatible implicit declaration of built-in functi on 'strcpy' traceroute.c:2755: warning: incompatible implicit declaration of built-in functi on 'strncpy' traceroute.c:2760: warning: incompatible implicit declaration of built-in functi on 'strcpy' traceroute.c:2762: warning: incompatible implicit declaration of built-in functi on 'strncpy' traceroute.c:2786: warning: incompatible implicit declaration of built-in functi on 'strstr' traceroute.c:2808: warning: incompatible implicit declaration of built-in functi on 'strcpy' traceroute.c:2811: warning: incompatible implicit declaration of built-in functi on 'strcat' traceroute.c:2815: warning: incompatible implicit declaration of built-in functi on 'strncpy' traceroute.c:2818: warning: incompatible implicit declaration of built-in functi on 'strncat' traceroute.c:2958: warning: incompatible implicit declaration of built-in functi on 'strcat' traceroute.c:2966: warning: incompatible implicit declaration of built-in functi on 'strcat' I didn't see dordata return a pointer and gcc -O -o traceroute-nano traceroute.c -lresolv -m didn't crash for me on x86. but I do suggest add -DSTRING on compiling command line because too many warnings and so easy to do. if you use -Wall you will see more warnings, anyway not a good program. dordata(ans,off,class,typ,fname,contact_ptr) unsigned char *ans; int off,class,typ; char *fname; char **contact_ptr; { int len = ntohs(getshort(ans+off)); int retval = off+len+2; int i,j; char name[256]; off += 2; switch (typ) { case T_SOA: name[0]=0; off = doname(ans,off,name); name[0]=0; off = doname(ans,off,name); *contact_ptr=name; return (0); default: return (0); } }
too old programming style, in this function never use i, j, len, retval..., class, fname it didn't return a pointer. sorry I misunderstood for return, but it returns name to contact_ptr. in this program only dorr calls dordata, and in dorr there is another name in it but we didn't use it as fname, why not remove reduant arguments and static name in dorr. also if typ is not T_SOA we didn't assign anything to contact_name, so it will get trouble in lookup_owner, it might be, I didn't read this code too much. but this code is not good enough. is this program worth to modify? dordata(ans,off,class,typ,fname,contact_ptr) unsigned char *ans; int off,class,typ; char *fname; char **contact_ptr; { int len = ntohs(getshort(ans+off)); int retval = off+len+2; int i,j; char name[256]; off += 2; switch (typ) { case T_SOA: name[0]=0; off = doname(ans,off,name); name[0]=0; off = doname(ans,off,name); *contact_ptr=name; return (0); default: return (0); } } dorr(ans,off,contact_ptr) unsigned char *ans; int off; char **contact_ptr; { int class, typ; char name[256]; name[0]=0; off = doname(ans,off,name); typ = ntohs(getshort(ans+off)); off = dotype(ans,off); class = ntohs(getshort(ans+off)); off = doclass(ans,off); off = dottl(ans,off); off = dordata(ans,off,class,typ,name,contact_ptr); return(off); }
From what I can see upstream is at least partly active so I suggest sending patches there as we only maintain ebuilds and not the applications ;)