Bug 197371

Summary: tar -X does not allow empty file
Product: Base System Reporter: Rudolf Čejka <cejkar>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Some People CC: re, rodrigo
Priority: ---    
Version: 10.1-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
archive_match.c.diff none

Description Rudolf Čejka 2015-02-06 13:18:08 UTC
Created attachment 152617 [details]
archive_match.c.diff

Please see https://code.google.com/p/libarchive/issues/detail?id=401

What steps will reproduce the problem?

1. Create empty file: touch z

2. Run: tar -tf/dev/null -X z

What is the expected output? What do you see instead?

What version are you using?

bsdtar 2.8.5 - libarchive 2.8.5 (as is in FreeBSD 9.3):

$ tar -tf/dev/null -X z
$

... empty output, good

bsdtar 3.1.2 - libarchive 3.1.2 (as is in FreeBSD 10.1):

$ tar -tf/dev/null -X z
tar: Error : Unrecognized archive format
$

Warning: The error is not about /dev/null archive format - it is about empty file z archive format, so the error is very misleading. File z could not be any archive in any case. You can try it with real tar file and you will suffer the same results.

I do not have deep knowledge of libarchive internals and reading of exclude list seems to be over-complicated to me, so I'm not sure about the correct solution, but something is included here.
Comment 1 Rodrigo Osorio freebsd_committer freebsd_triage 2015-02-06 14:42:49 UTC
Hi Rudolf,

Apparently this issue was resolved 27 days ago by this commit[1],
and looks like the bug reports the same issue[2].

At this point no new release of libarchive is available,
probably a new version is required for HEAD and 10-stable
in order to fix this issue.

Hope this help.
- rodrigo

[1] https://github.com/libarchive/libarchive/commit/f93e32f4a2e4b67b05d9042346439c169c03a39d
[2] https://code.google.com/p/libarchive/issues/detail?id=327
Comment 2 Tobias Kortkamp freebsd_committer freebsd_triage 2018-11-02 12:31:38 UTC
This works as expected on >= 11.2 with bsdtar >= 3.3.2.