Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 37132 - New tar fails to unpack certain archives properly
Summary: New tar fails to unpack certain archives properly
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All All
: High critical (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
: 36810 37103 37157 37170 37176 37190 37195 37202 37203 37287 37352 37610 38739 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-01-03 12:05 UTC by Daniel Ahlberg (RETIRED)
Modified: 2004-01-19 21:25 UTC (History)
18 users (show)

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


Attachments
ebuild.sh.diff (ebuild.sh.diff,329 bytes, patch)
2004-01-03 12:40 UTC, Tony Vroon (RETIRED)
Details | Diff
1.13.92-disable-dotslash-check.diff (1.13.92-disable-dotslash-check.diff,282 bytes, patch)
2004-01-03 13:14 UTC, Tony Vroon (RETIRED)
Details | Diff
tar-1.13.92.ebuild.diff (tar-1.13.92.ebuild.diff,357 bytes, patch)
2004-01-03 13:15 UTC, Tony Vroon (RETIRED)
Details | Diff
1.13.92-hardcode-absolute-names-to-on.diff (1.13.92-hardcode-absolute-names-to-on.diff,413 bytes, patch)
2004-01-03 13:58 UTC, Tony Vroon (RETIRED)
Details | Diff
tar-1.13.92.ebuild.diff (tar-1.13.92.ebuild.diff,396 bytes, patch)
2004-01-03 13:59 UTC, Tony Vroon (RETIRED)
Details | Diff
tar-1.13.92-fix-pathstrip.patch (tar-1.13.92-fix-pathstrip.patch,356 bytes, patch)
2004-01-06 10:58 UTC, Martin Schlemmer (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Ahlberg (RETIRED) gentoo-dev 2004-01-03 12:05:07 UTC
Some tar archives has paths like these in them: ..././...
when trying to unpack these archives with tar 1.13.92 it gives the following warning: tar: Removing leading ...

Confirmed tarballs that suffers from this are: libpcap-0.8.1, tcpdump-3.8.1 and iptables-1.2.9
Comment 1 Tony Vroon (RETIRED) gentoo-dev 2004-01-03 12:10:47 UTC
The tar problem manifests itself like this:

>>> md5 src_uri ;-) tcpdump-3.8.1.tar.gz
>>> Unpacking source...
>>> Unpacking tcpdump-3.8.1.tar.gz to /var/tmp/portage/tcpdump-3.8.1/work
tar: Removing leading `tcpdump-3.8.1/./' from member names
>>> Source unpacked.

!!! ERROR: net-analyzer/tcpdump-3.8.1 failed.
!!! Function econf, Line 341, Exitcode 1
!!! no configure script found

And those weird paths are actually in the mentioned tar's:
tcpdump-3.8.1/./
tcpdump-3.8.1/./lbl/
tcpdump-3.8.1/./lbl/os-osf4.h
(truncated)
Comment 2 Daniel Ahlberg (RETIRED) gentoo-dev 2004-01-03 12:13:21 UTC
The result is that tar strips out the subdir in the tarball unpacking it directly to $PORTAGE_TMDIR/work and not $PORTAGE_TMPDIR/work/libpcap-0.8.1
Comment 3 Tony Vroon (RETIRED) gentoo-dev 2004-01-03 12:21:00 UTC
A fragment from tar-1.13.92/ChangeLog
One entry seems relevant, marked with <!>

003-11-14  Sergey Poznyakoff  <gray@Mirddin.farlep.net>

        * src/tar.h (archive_format): USTAR_FORMAT: New type.
        * src/create.c: Added POSIX.1-1988 support.
    <!>* src/names.c (safer_name_suffix): Skip leading ./
        * src/tar.c: New option --format=ustar forces
        POSIX.1-1988 archive format.
        * tests/delete03.sh: Updated.
        * tests/extrac04.sh: Updated.
        * tests/multiv01.sh: Updated.
Comment 4 Tony Vroon (RETIRED) gentoo-dev 2004-01-03 12:34:48 UTC
Looks as if the "P" option to tar (--absolute-names) disables the check.
Playing around with this.
Comment 5 Tony Vroon (RETIRED) gentoo-dev 2004-01-03 12:40:33 UTC
Created attachment 23085 [details, diff]
ebuild.sh.diff

This adds --absolute-names to the unpack command in ebuild.sh and allows me to
install libpcap.
Please perform a sanity check on this and treat it with care until I've tested
more thoroughly.
Comment 6 SpanKY gentoo-dev 2004-01-03 12:42:11 UTC
i dont really think the way to go is patching ebuild.sh

it's obvious it's a bug in tar, fix tar and we dont have to screw around with releasing another portage
Comment 7 Tony Vroon (RETIRED) gentoo-dev 2004-01-03 12:45:56 UTC
Tested with:  libpcap-0.8.1, tcpdump-3.8.1 and iptables-1.2.9
These weren't willing to install earlier and work now.

Tested with: kdegames-3.2.0_beta2, tar-1.13.92 and portage-2.0.49-r20
These worked before, and still work now.
Comment 8 Tony Vroon (RETIRED) gentoo-dev 2004-01-03 12:47:02 UTC
I'm not a C coder though.

Could mask the tar version, file a bug upstream or have someone else hack on names.c, I guess.

Anyway, should anyone be willing to take this route, it will work.
Comment 9 Tony Vroon (RETIRED) gentoo-dev 2004-01-03 13:14:27 UTC
Created attachment 23092 [details, diff]
1.13.92-disable-dotslash-check.diff

This hardcodes the (apparently buggy) check to disabled in the tar sources.
Basically, this is the same solution as provided earlier, but then in a way
that doesn't require a portage upgrade (which would be tedious indeed, SpanKY,
agreed).
Comment 10 Tony Vroon (RETIRED) gentoo-dev 2004-01-03 13:15:20 UTC
Created attachment 23093 [details, diff]
tar-1.13.92.ebuild.diff

And ofcourse the diff to the tar ebuild to apply this diff.

How's this? (Tested again, same 6 packages)
Comment 11 SpanKY gentoo-dev 2004-01-03 13:50:55 UTC
absolute_names_option is referenced in both src/extract.c and src/names.c, so perhaps the better way of doing it is to patch src/tar.c around line 1246 with absolute_names_option = true;
Comment 12 Tony Vroon (RETIRED) gentoo-dev 2004-01-03 13:58:43 UTC
Created attachment 23099 [details, diff]
1.13.92-hardcode-absolute-names-to-on.diff

Redoing things the hardcoded way, in tar.c, as asked.
Comment 13 Tony Vroon (RETIRED) gentoo-dev 2004-01-03 13:59:37 UTC
Created attachment 23100 [details, diff]
tar-1.13.92.ebuild.diff

And the ebuild change to have the patch applied.

Bugfixes to order, anyone else that would like a change? :)
Comment 14 SpanKY gentoo-dev 2004-01-03 21:54:31 UTC
*** Bug 37157 has been marked as a duplicate of this bug. ***
Comment 15 Daniel Ahlberg (RETIRED) gentoo-dev 2004-01-04 02:52:35 UTC
*** Bug 37170 has been marked as a duplicate of this bug. ***
Comment 16 Daniel Ahlberg (RETIRED) gentoo-dev 2004-01-04 03:58:59 UTC
*** Bug 36810 has been marked as a duplicate of this bug. ***
Comment 17 Daniel Ahlberg (RETIRED) gentoo-dev 2004-01-04 04:00:03 UTC
*** Bug 37103 has been marked as a duplicate of this bug. ***
Comment 18 jochen 2004-01-04 04:55:38 UTC
*** Bug 37176 has been marked as a duplicate of this bug. ***
Comment 19 Bryan Østergaard (RETIRED) gentoo-dev 2004-01-04 06:41:14 UTC
*** Bug 37190 has been marked as a duplicate of this bug. ***
Comment 20 Brandon Hale (RETIRED) gentoo-dev 2004-01-04 08:06:09 UTC
*** Bug 37195 has been marked as a duplicate of this bug. ***
Comment 21 Seemant Kulleen (RETIRED) gentoo-dev 2004-01-04 08:54:58 UTC
thanks for the patch, Tony, added to portage and reporting this issue upstream
Comment 22 Seemant Kulleen (RETIRED) gentoo-dev 2004-01-04 09:16:32 UTC
*** Bug 37202 has been marked as a duplicate of this bug. ***
Comment 23 Seemant Kulleen (RETIRED) gentoo-dev 2004-01-04 09:26:15 UTC
*** Bug 37203 has been marked as a duplicate of this bug. ***
Comment 24 Seemant Kulleen (RETIRED) gentoo-dev 2004-01-05 04:29:03 UTC
*** Bug 37287 has been marked as a duplicate of this bug. ***
Comment 25 Haroon Rafique 2004-01-05 11:05:11 UTC
For the slow people among us (who need everything spelled out), the fix is to:
a) emerge tar, and then
b) emerge libpcap.
tar version app-arch/tar-1.13.92-r1 seems to address the problem mentioned here.
Comment 26 Martin Schlemmer (RETIRED) gentoo-dev 2004-01-06 10:53:46 UTC
I do not think this is the proper fix ..
Comment 27 Martin Schlemmer (RETIRED) gentoo-dev 2004-01-06 10:58:45 UTC
Created attachment 23245 [details, diff]
tar-1.13.92-fix-pathstrip.patch

The problem is the strip code also strip './', and not just '../'.  I do not
see why the code also strip './', as it refers to the current dir (or the
proper file if you append the path given to -C arg), and as we all know, RH
etc starts to ship tarballs that have pathnames start with './' for security
reasons - same reason why unzip add './' to all paths.

Anyhow, attached is patch that fixes the code not to stip './'.

Comments?
Comment 28 Martin Schlemmer (RETIRED) gentoo-dev 2004-01-06 11:05:36 UTC
On another matter - if you look at the following code:

--
          if (p[0] == '.')
            {
              if (p[1] == '.' && (ISSLASH (p[2]) || !p[2]))
                prefix_len = p + 2 - file_name;
              else if (ISSLASH (p[1]))
                prefix_len = p + 1 - file_name;
            }
--

from src/names.c ('safer_name_suffix' function), is it safe?  I see no
test to see if the lenght of the input filename is >= 3 chars, but still
the code checks p[0], p[1] and p[2] without checking if its valid (sure,
there is the '!p[2]' check, but that follows 'ISSLASH (p[2])').  My C
is a bit rustic, so I might see something where there is none ...
Comment 29 Luca Barbato gentoo-dev 2004-01-06 11:25:16 UTC
if the string is 0 terminated should not be a problem:

if p[1] == 0 it exits and won't check the other conditions.

Maybe I forgot something, from a quick look at the rest of the code it should not cause any harm.
Comment 30 Martin Schlemmer (RETIRED) gentoo-dev 2004-01-06 11:39:49 UTC
If p[2] is out of bounds, the 'ISSLASH (p[2])' will touch it.  The p==0 test
is only after, and this is not part of that while loop ...
Comment 31 Martin Schlemmer (RETIRED) gentoo-dev 2004-01-06 14:04:12 UTC
Ok, here is the proper fix:

http://savannah.gnu.org/cgi-bin/viewcvs/tar/tar/src/names.c.diff?r1=1.36&r2=1.37&diff_format=u

I missed a change it seems :)  I'll commit tonight if somebody do not get there
before me.

Comment 32 Randy Tupas 2004-01-07 02:21:03 UTC
I suffered from the exact same problem. After upgrading app-arch/tar-1.13.92 to 1.13.92-r1, I was able to successfully upgrade libpcap and iptables.
Comment 33 SpanKY gentoo-dev 2004-01-07 22:17:51 UTC
*** Bug 37352 has been marked as a duplicate of this bug. ***
Comment 34 Tony Vroon (RETIRED) gentoo-dev 2004-01-07 23:06:05 UTC
Comment on attachment 23099 [details, diff]
1.13.92-hardcode-absolute-names-to-on.diff

This workaround is no longer necessary now that the true cause is found.
Obsoleting.
Comment 35 SpanKY gentoo-dev 2004-01-08 17:17:27 UTC
*** Bug 37610 has been marked as a duplicate of this bug. ***
Comment 36 Andreas Proschofsky (RETIRED) gentoo-dev 2004-01-10 04:47:41 UTC
http://bugs.gentoo.org/show_bug.cgi?id=37728

Seems to be a duplicate of this one too, openoffice and openoffice-ximian both break with the current unstable app-arch/tar-1.13.92-r1
Comment 37 Martin Schlemmer (RETIRED) gentoo-dev 2004-01-11 06:02:17 UTC
Added -r2 with new patch - can we verify that it still works?

Comment 38 Martin Schlemmer (RETIRED) gentoo-dev 2004-01-11 08:12:14 UTC
Ok, seems this also fixes the openoffice issues with -r1 (bug #37610).
Comment 39 SpanKY gentoo-dev 2004-01-19 21:25:28 UTC
*** Bug 38739 has been marked as a duplicate of this bug. ***