[File] [PATCH] Magdir: remove some duplicated magic entries

Christos Zoulas christos at zoulas.com
Fri Aug 30 17:07:56 UTC 2024



> On Aug 29, 2024, at 12:31 PM, Alexandre IOOSS <erdnaxe at crans.org> wrote:
> 
> Hello,
> 
> Following the change in apprentice_sort(), we now have some "Duplicate magic entry" warnings to fix.
> 
> Attached you may find a patch that merges the following magic:
> - Apple ][ QBoot/0Boot Image (magic/Magdir/apple): can be merged as the subbranches match different strings.
> - Mach-o and Java (magic/Magdir/cafebabe): can be merged as the mach-o branch is "belong 1" and the java one is "ubelong >30".
> - Alpha COFF object file (magic/Magdir/digital): can be merged as one branch is "leshort 0" and the other one "leshort !0".
> - PowerPC COFF object file (magic/Magdir/coff): same as Alpha COFF object file.
> 

Applied, thanks.

BTW merging duplicate entries does not fix ambiguity that depends on sorting order. For example

[magic 1]
0	string	foo
>20	string	bar	A bar file


0	string	foo
>30	string	baz	A baz file

Changed into:

[magic 2]
0	string	foo
>20	string	bar	A bar file
>30	string	baz	A baz file

Will still behave differently than:

[magic 3]
0	string	foo
>30	string	baz	A baz file
>20	string	bar	A bar file

So for a file that contains foo in offset 0 bar in offset 20 and baz in offset 30.
Using [magic 1] will either print 
"A bar file"
or 
"A baz file"
depending on the ordering the two magic entries have been found. 

Using [magic 2] it will print
"A bar file A baz file"

and using [magic 3] it will print
"A baz file A bar file"


I think that merging the entries makes sense, but we need to make sure
that the combined entries work properly.

Best,

christos







More information about the File mailing list