Bug#876316: file: buggy magic: mistakes many things (including .gz) as "DOS/MBR boot sector", caused by commit 51ceb2bd7a728fb307f190ee68fe53cd0392fb28

2017-09-20 Thread Ximin Luo
Ximin Luo:
> [..] One example is attached.
> 

Whoops, here it is attached for real.

-- 
GPG: ed25519/56034877E1F87C35
GPG: rsa4096/1318EFAC5FBBDBCE
https://github.com/infinity0/pubkeys.git


control.tar.gz
Description: application/gzip


Bug#876316: file: buggy magic: mistakes many things (including .gz) as "DOS/MBR boot sector", caused by commit 51ceb2bd7a728fb307f190ee68fe53cd0392fb28

2017-09-20 Thread Ximin Luo
Package: file
Version: 1:5.32-1
Severity: important
Tags: upstream
Control: affects -1 diffoscope

Dear Maintainer,

(I would have filed this upstream but their bug tracker was down.)

In developing diffoscope we've come across many cases of file(1) misdetecting
other things as DOS/MBR boot sector. I've been dismissing these as corner cases
but now there are just too many to ignore. One example is attached.

$ file control.tar.gz 
control.tar.gz: DOS/MBR boot sector; partition 1 : ID=0xd8, [..]

I git cloned https://github.com/file/file and ran my tests:

| (master)$ git clean -fdx && git reset --hard && autoreconf -i && ./configure 
&& make && src/file -m magic/magic:magic/magic.mgc ../control.tar.gz
| [..]
| ../control.tar.gz: DOS/MBR boot sector; partition 1 : [..]

After some experimenting I found a good commit:

| $ git checkout FILE5_00
| $ git clean -fdx && git reset --hard && autoreconf -i && ./configure && make 
&& src/file -m magic/magic:magic/magic.mgc ../control.tar.gz
| [..]
| ../control.tar.gz: gzip compressed data, from Unix, max compression

So we have a good and a bad revision, let's run a git-bisect then.

$ git bisect start
$ git bisect good FILE5_00
$ git bisect bad origin/master 
$ git bisect run sh -c 'git clean -fdx && git reset --hard && autoreconf -i && 
./configure && make && src/file -m magic/magic:magic/magic.mgc 
../control.tar.gz | grep -i gzip; x=$?; git reset --hard; git clean -fdx; exit 
$x'
[..]
51ceb2bd7a728fb307f190ee68fe53cd0392fb28 is the first bad commit
commit 51ceb2bd7a728fb307f190ee68fe53cd0392fb28
Author: Christos Zoulas 
Date:   Fri Oct 12 16:10:39 2012 +

from Joerg Jenderek
Hi,
2 files (TDSK-5120x32b.img and TDSK-5120x64b.img ) in directory bootsector
are characterized wrong ( see output bootsector-5.11.txt) .
[..]
:04 04 b0a083f5b8453b812de42749e612aff7673b42f3 
ef0015db2bdd886d15d6993c66d6562fed5572e6 M  magic
bisect run success

X

-- System Information:
Debian Release: buster/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable-debug'), (500, 
'testing-debug'), (500, 'buildd-unstable'), (300, 'unstable'), (100, 
'experimental'), (1, 'experimental-debug')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.12.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8), LANGUAGE=en_GB:en 
(charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages file depends on:
ii  libc6  2.24-17
ii  libmagic1  1:5.32-1
ii  zlib1g 1:1.2.8.dfsg-5

file recommends no packages.

file suggests no packages.

-- no debconf information