Bug 264 - doesn't handle nested magic patterns properly
Summary: doesn't handle nested magic patterns properly
Status: RESOLVED FIXED
Alias: None
Product: xdgmime
Classification: Unclassified
Component: xdgmime (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: high normal
Assignee: Jonathan Blandford
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-03 11:29 UTC by Christophe Fergeau
Modified: 2004-03-10 00:52 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
proposed patch (3.21 KB, patch)
2004-03-03 11:30 UTC, Christophe Fergeau
Details | Splinter Review

Description Christophe Fergeau 2004-03-03 11:29:40 UTC
I'm pasting from http://bugzilla.gnome.org/show_bug.cgi?id=136071 (which has two
different patches to solve the problem)

« The attached patch fixes a bug with the xdgmime code where any elf
executable file would be sniffed as an application/x-core file. This
happens because of a bug in xdgmimemagic.c when the magic for a mime
type is composed of several 'indented' patterns.
xdgmimemagic.c reads the patterns one by one, and each time it has read
one pattern, it prepends them at the beginning of a list. With a file
created from
<match .... />         <- indent 0
<match ....>           <- indent 0
  <match ....>         <- indent 1
     <match ... />     <- indent 2
  </match>
</match>
you'd have in memory a list composed of
(pattern with indent 2), (pattern with indent 1), (pattern with indent
0), (pattern with indent 0)

On the other hand, the code in _xdg_mime_magic_matchlet_compare_level
assumes that the list it processes contains the parsed indented patterns
in the same order as the magic file, which caused the misdetection of
the mime type of those elf executables.

I fixed that by mirroring the list of patterns, the place where I'm
doing it may not be appropriate, but files in /bin are now properly
identified as executable files. »
Comment 1 Christophe Fergeau 2004-03-03 11:30:01 UTC
Created attachment 118 [details] [review]
proposed patch
Comment 2 Christophe Fergeau 2004-03-05 01:09:54 UTC
I committed this patch to gnome-vfs HEAD. So far it works fine on my two systems.
Comment 3 Jonathan Blandford 2004-03-10 19:52:31 UTC
Applied, thanks.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.