[Reproducible-builds] Bug#788364: libmagic1: misdetect some Coreboot images as text

Reiner Herrmann reiner at reiner-h.de
Thu Sep 3 22:33:57 UTC 2015


Hi Lunar,

On Thu, Sep 03, 2015 at 04:26:57PM +0200, Jérémy Bobbio wrote:
> diffoscope uses libmagic (through its Python bindings) to identify the
> format of the files its trying to compare. Some coreboot images are
> misdetected as text files which results in garbled diffoscope output.
> 
> Proper way to detect Coreboot images is probably to look for a CBFS
> header. cbfs_find_header() is how upstream does it:
> http://review.coreboot.org/gitweb?p=coreboot.git;a=blob;f=util/cbfstool/cbfs_image.c;h=c40bd6641
> 
> I could tell diffoscope to detect Coreboot images with a similar
> mechanism but it would probably be better to teach libmagic to do it.
> Is that easily doable?
> 
> Reiner Herrmann:
> > file detects them as plain-text:
> > 
> > > /tmp/b1_coreboot.rom: ISO-8859 text, with very long lines, with no line terminators
> > > /tmp/b2_coreboot.rom: ISO-8859 text, with very long lines, with no line terminators
> > 
> > That's why diffoscope also treats them as text.
> > I'm not sure this can/should be fixed inside diffoscope, as we rely on
> > libmagic detecting them correctly.
> 
> Reiner, I remember you had a look into this during DebConf. Have you
> made any progress?

Unfortunately I haven't found any easy solution to it.
It looked like magic(5) files require constant offsets for
checking magic numbers.
And I also didn't see a way to look at an offset backwards from the end
of a file (where CBFS images have an offset to the header).

I just had another look and saw that the "type" field can also be a
search. So it could be possible to detect them via pattern files.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/reproducible-builds/attachments/20150904/7e756dd2/attachment.sig>


More information about the Reproducible-builds mailing list