[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
tar hangs on dangling symlink when extracting with --wildcards
From: |
Tristan Miller |
Subject: |
tar hangs on dangling symlink when extracting with --wildcards |
Date: |
Mon, 27 May 2024 11:12:12 -0500 |
User-agent: |
Mozilla Thunderbird |
Greetings.
I believe I've discovered a bug in GNU tar 1.35 that occurs when using
--wildcards to extract a symlink to another file in the archive that
does not match the wildcard.
An example of an archive that can reproduce this problem is at
<http://files.nothingisreal.com/tmp/news002f1.tar.bz2>. Using the
command line
tar xavf news002f1.tar.bz2
the archive is successfully extracted. But if I add a --wildcards
option, such as
tar xavf news002f1.tar.bz2 --wildcards '*trek*'
then tar hangs when it gets to the file news002f1/b5/net.startrek/24.
This file, which matches the wildcard, is a symlink to the file
news002f1/b5/net.sf-lovers/141, which does not match the wildcard.
Running tar with strace shows it's stuck in a loop:
mkdirat(AT_FDCWD, "news002f1", 0755) = -1 EEXIST (File exists)
mkdirat(AT_FDCWD, "news002f1/b5", 0755) = -1 EEXIST (File exists)
mkdirat(AT_FDCWD, "news002f1/b5/net.startrek", 0755) = -1 EEXIST (File
exists)
newfstatat(AT_FDCWD, "news002f1/b5/net.startrek", {st_mode=S_IFDIR|0755,
st_size=4096, ...}, 0) = 0
linkat(AT_FDCWD, "news002f1/b5/net.sf-lovers/141", AT_FDCWD,
"news002f1/b5/net.startrek/24", 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "news002f1/b5/net.sf-lovers/141", 0x7fffcaca26a0,
AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)
I'm not sure what tar *should* be doing in a case like this; probably it
depends on other command-line options that handle symlinks. Perhaps it
should extract the symlink (leaving it dangling to a non-existent
referent) and emit a warning, or refuse to extract the symlink and emit
a warning. But I don't think it should just hang.
Regards,
Tristan
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Tristan Miller
Free Software developer, ferret herder, logologist
https://logological.org/
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- tar hangs on dangling symlink when extracting with --wildcards,
Tristan Miller <=