Bug 1225407 - GNU tar hangs when extracting certain hard links
Summary: GNU tar hangs when extracting certain hard links
Status: NEW
Alias: None
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Basesystem (show other bugs)
Version: Current
Hardware: Other Other
: P5 - None : Normal with 1 vote (vote)
Target Milestone: ---
Assignee: Antonio Teixeira
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-27 18:49 UTC by Tristan Miller
Modified: 2024-07-10 17:13 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tristan Miller 2024-05-27 18:49:45 UTC
The version of GNU tar 1.35 packaged for openSUSE Tumbleweed hangs when using --wildcards to extract a symlink to another file in the archive that does not match the wildcard.  The problem may be specific to the openSUSE RPMs; I cannot reproduce it when using GNU tar 1.35 compiled from source.

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 that tar gets 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)

By contrast, GNU tar 1.35 compiled from source does not hang; it instead emits the error messages of the following sort for the affected symlinks and then continues processing the archive:

Cannot hard link to ‘news002f1/b5/net.sf-lovers/141’: No such file or directory
Comment 1 Tristan Miller 2024-05-28 13:37:55 UTC
s/symlink/hard link/g