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).
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
looks good, thanks http://sources.gentoo.org/gentoo-projects/pax-utils/scanelf.c?r1=1.193&r2=1.194