<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>143935</bug_id>
          
          <creation_ts>2006-08-14 13:19 0000</creation_ts>
          <short_desc>net-analyzer/traceroute-nanog-6.3.10-r1 prints out cruft with -O flag</short_desc>
          <delta_ts>2007-05-23 09:06:05 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Applications</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>UPSTREAM</resolution>
          
          
          
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>brodigan@pdx.edu</reporter>
          <assigned_to>netmon@gentoo.org</assigned_to>
          

      

      
          <long_desc isprivate="0">
            <who>brodigan@pdx.edu</who>
            <bug_when>2006-08-14 13:19:25 0000</bug_when>
            <thetext>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=&quot;amd64&quot;
AUTOCLEAN=&quot;yes&quot;
CBUILD=&quot;x86_64-pc-linux-gnu&quot;
CFLAGS=&quot;-O2 -pipe&quot;
CHOST=&quot;x86_64-pc-linux-gnu&quot;
CONFIG_PROTECT=&quot;/etc /usr/share/X11/xkb&quot;
CONFIG_PROTECT_MASK=&quot;/etc/env.d /etc/gconf /etc/revdep-rebuild /etc/terminfo&quot;
CXXFLAGS=&quot;-O2 -pipe&quot;
DISTDIR=&quot;/usr/portage/distfiles&quot;
FEATURES=&quot;autoconfig distlocks metadata-transfer sandbox sfperms strict&quot;
GENTOO_MIRRORS=&quot;http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo&quot;
PKGDIR=&quot;/usr/portage/packages&quot;
PORTAGE_RSYNC_OPTS=&quot;--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=&apos;/distfiles&apos; --exclude=&apos;/local&apos; --exclude=&apos;/packages&apos;&quot;
PORTAGE_TMPDIR=&quot;/var/tmp&quot;
PORTDIR=&quot;/usr/portage&quot;
SYNC=&quot;rsync://rsync.gentoo.org/gentoo-portage&quot;
USE=&quot;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&quot;
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS, MAKEOPTS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>brodigan@pdx.edu</who>
            <bug_when>2006-08-14 13:20:47 0000</bug_when>
            <thetext>Created an attachment (id=94268)
traceroute-nanog-6.3.10.patch

This patch fixes dordata.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jakub@gentoo.org</who>
            <bug_when>2006-08-14 13:56:50 0000</bug_when>
            <thetext>Doesn&apos;t look amd64-specific...</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vanquirius@gentoo.org</who>
            <bug_when>2006-12-14 19:29:06 0000</bug_when>
            <thetext>Hello,

Would you mind giving an example? I tested the -O switch and saw no effect.

Cheers,
Marcelo</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>brodigan@pdx.edu</who>
            <bug_when>2006-12-14 20:52:48 0000</bug_when>
            <thetext>Hmm I can&apos;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.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>dragonlinux@gmail.com</who>
            <bug_when>2007-01-29 01:53:07 0000</bug_when>
            <thetext>ebuild:
src_compile() {
    $(tc-getCC) traceroute.c -o ${PN} ${CFLAGS} -lresolv -lm || die &quot;Compile failed&quot;
}

19:59:25 (18.96 KB/s) - `/usr/portage/distfiles/traceroute-nanog_6.3.10-2.diff.gz&apos; 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 ]
&gt;&gt;&gt; Unpacking source...
&gt;&gt;&gt; Unpacking traceroute-nanog_6.3.10.orig.tar.gz to /var/tmp/portage/net-analyzer/traceroute-nanog-6.3.10-r1/work
&gt;&gt;&gt; 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 ]
&gt;&gt;&gt; Source unpacked.
&gt;&gt;&gt; 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 &apos;main&apos;:
traceroute.c:1180: warning: incompatible implicit declaration of built-in function &apos;strncpy&apos;
traceroute.c:1209: warning: incompatible implicit declaration of built-in function &apos;strncpy&apos;
traceroute.c: In function &apos;print_from&apos;:
traceroute.c:2322: warning: incompatible implicit declaration of built-in function &apos;memcpy&apos;
traceroute.c: In function &apos;inetname&apos;:
traceroute.c:2393: warning: incompatible implicit declaration of built-in function &apos;strcpy&apos;
traceroute.c:2408: warning: incompatible implicit declaration of built-in function &apos;strncpy&apos;
traceroute.c: In function &apos;lookup_owner&apos;:
traceroute.c:2468: warning: incompatible implicit declaration of built-in function &apos;strchr&apos;
traceroute.c:2472: warning: incompatible implicit declaration of built-in function &apos;strlen&apos;
traceroute.c: In function &apos;get_origin&apos;:
traceroute.c:2646: warning: incompatible implicit declaration of built-in function &apos;strcpy&apos;
traceroute.c:2648: warning: incompatible implicit declaration of built-in function &apos;strncpy&apos;
traceroute.c:2674: warning: incompatible implicit declaration of built-in function &apos;strcpy&apos;
traceroute.c:2676: warning: incompatible implicit declaration of built-in function &apos;strncpy&apos;
traceroute.c:2711: warning: incompatible implicit declaration of built-in function &apos;strlen&apos;
traceroute.c:2719: warning: incompatible implicit declaration of built-in function &apos;strcpy&apos;
traceroute.c:2744: warning: incompatible implicit declaration of built-in function &apos;strcpy&apos;
traceroute.c:2746: warning: incompatible implicit declaration of built-in functi
on &apos;strncpy&apos;
traceroute.c:2753: warning: incompatible implicit declaration of built-in functi
on &apos;strcpy&apos;
traceroute.c:2755: warning: incompatible implicit declaration of built-in functi
on &apos;strncpy&apos;
traceroute.c:2760: warning: incompatible implicit declaration of built-in functi
on &apos;strcpy&apos;
traceroute.c:2762: warning: incompatible implicit declaration of built-in functi
on &apos;strncpy&apos;
traceroute.c:2786: warning: incompatible implicit declaration of built-in functi
on &apos;strstr&apos;
traceroute.c:2808: warning: incompatible implicit declaration of built-in functi
on &apos;strcpy&apos;
traceroute.c:2811: warning: incompatible implicit declaration of built-in functi
on &apos;strcat&apos;
traceroute.c:2815: warning: incompatible implicit declaration of built-in functi
on &apos;strncpy&apos;
traceroute.c:2818: warning: incompatible implicit declaration of built-in functi
on &apos;strncat&apos;
traceroute.c:2958: warning: incompatible implicit declaration of built-in functi
on &apos;strcat&apos;
traceroute.c:2966: warning: incompatible implicit declaration of built-in functi
on &apos;strcat&apos;

I didn&apos;t see dordata return a pointer and gcc -O -o traceroute-nano traceroute.c -lresolv -m didn&apos;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);
    }
}
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>dragonlinux@gmail.com</who>
            <bug_when>2007-01-29 02:21:46 0000</bug_when>
            <thetext>too old programming style, 
in this function never use i, j, len, retval..., class, fname

it didn&apos;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&apos;t use it as fname, why not remove reduant arguments and static name in dorr.
also if typ is not T_SOA we didn&apos;t assign anything to contact_name, so it will get trouble in lookup_owner, it might be, I didn&apos;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);
}
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jokey@gentoo.org</who>
            <bug_when>2007-05-23 09:06:05 0000</bug_when>
            <thetext>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 ;)</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>94268</attachid>
            <date>2006-08-14 13:20 0000</date>
            <desc>traceroute-nanog-6.3.10.patch</desc>
            <filename>traceroute-nanog-6.3.10.patch</filename>
            <type>text/plain</type>
            <data encoding="base64">LS0tIHRyYWNlcm91dGUuYy5vcmlnCTIwMDYtMDgtMTQgMjA6MDE6MDEuMDAwMDAwMDAwICswMDAw
CisrKyB0cmFjZXJvdXRlLmMJMjAwNi0wOC0xNCAyMDowMToxNy4wMDAwMDAwMDAgKzAwMDAKQEAg
LTI5OTcsNyArMjk5Nyw3IEBACiAgICAgaW50IGxlbiA9IG50b2hzKGdldHNob3J0KGFucytvZmYp
KTsKICAgICBpbnQgcmV0dmFsID0gb2ZmK2xlbisyOwogICAgIGludCBpLGo7Ci0gICAgY2hhciBu
YW1lWzI1Nl07CisgICAgc3RhdGljIGNoYXIgbmFtZVsyNTZdOwogCiAgICAgb2ZmICs9IDI7CiAg
ICAgc3dpdGNoICh0eXApIHsK
</data>        

          </attachment>
    </bug>

</bugzilla>