Bug 11531

Summary: tar: archive with first member named BZh[1-9] is not handled correctly
Product: Busybox Reporter: Michał Górny <mgorny>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: 1.33.x   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description Michał Górny 2018-11-26 18:00:36 UTC
If the first .tar member is named BZh[1-9], the archive is incorrectly recognized as bzip2-compressed:

$ busybox tar -xf ustar.tar 
tar: bunzip error -2
tar: short read

While such a filename is not very likely, it's a technically valid tarball.

To reproduce:
$ echo test > BZh5
$ tar -cf ustar.tar BZh5
Comment 1 Denys Vlasenko 2018-11-27 10:27:42 UTC
Fixed in git:

commit f4fc303e3679e4ab0d45f60c31f9b687f27f7452 (HEAD -> master)
Date:   Tue Nov 27 11:26:48 2018 +0100

    tar: fix too eager autodetection