Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 236539 - scanelf uses dirty memory possibly resulting in garbage
Summary: scanelf uses dirty memory possibly resulting in garbage
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: x86 Solaris
: High normal (vote)
Assignee: solar (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-03 08:01 UTC by Fabian Groffen
Modified: 2008-09-29 06:05 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fabian Groffen gentoo-dev 2008-09-03 08:01:01 UTC
consider the current CVS output of scanelf on Solaris:

% ./scanelf -vvv -a $EPREFIX/usr/bin/vim
Format: X%o %x %O %D %e %t %r %b %F 
/Library/Gentoo/usr/bin/vim: scanning file {ELFCLASS32,ELFDATA2LSB}
 TYPE    PAX   PERM ENDIAN STK/REL/PTL TEXTREL RPATH BIND FILE 
XET_EXEC ---xe- 0755 LE --- R-- RW-    -    /Library/Gentoo/usr/i386-pc-ris2.10/lib/gcc:/Library/Gentoo/usr/i386-pc-solaris2.10/lib:/Library/Gentoo/usr/lib:/Library/Gentoo/lib LAZY /Library/Gentoo/usr/bin/vim 

(note the X on the start)

With this patch to make sure strcat actually starts at the begin of the allocated string, the garbage is gone:

@@ -1903,6 +1909,7 @@
        } else {
                size_t fmt_len = 30;
                out_format = xmalloc(sizeof(char) * fmt_len);
+               *out_format = '\0';
                if (!be_quiet)     xstrcat(&out_format, "%o ", &fmt_len);
                if (show_pax)      xstrcat(&out_format, "%x ", &fmt_len);
                if (show_perms)    xstrcat(&out_format, "%O ", &fmt_len);

% ./scanelf -vvv -a $EPREFIX/usr/bin/vim
Format: %o %x %O %D %e %t %r %b %F 
/Library/Gentoo/usr/bin/vim: scanning file {ELFCLASS32,ELFDATA2LSB}
 TYPE    PAX   PERM ENDIAN STK/REL/PTL TEXTREL RPATH BIND FILE 
ET_EXEC ---xe- 0755 LE --- R-- RW-    -    /Library/Gentoo/usr/i386-pc-solaris2.10/lib/gcc:/Library/Gentoo/usr/i386-pc-solaris2.10/lib:/Library/Gentoo/usr/lib:/Library/Gentoo/lib LAZY /Library/Gentoo/usr/bin/vim 


I only see the problem on Solaris/x86, not on Solaris/Sparc and Darwin/ppc, but I believe the behaviour is correct, considering the contracts of malloc and strcat (as called by the xwrappers).
Comment 1 Fabian Groffen gentoo-dev 2008-09-21 11:32:51 UTC
 TYPE    PAX   FILE 
�`aET_EXEC PemRxS /gentoo/prefix64/var/tmp/portage/dev-java/sun-jdk-1.5.0.16/work/jdk1.5.0_16/bin/appletviewer 

so same problem on x64-solaris (OpenSolaris/64-bits)

my patch also fixes the issue here