Bug 21679

Summary: update-mime-database should handle empty magic elements
Product: shared-mime-info Reporter: Marius Vollmer <marius.vollmer>
Component: generalAssignee: Shared Mime Info group <shared_mime_info>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Don't crash in write_match when magic->matches is NULL.

Description Marius Vollmer 2009-05-11 07:34:22 UTC
Created attachment 25730 [details] [review]
Don't crash in write_match when magic->matches is NULL.

A empty <magic/> element causes update-mime-database to crash, like this example:

<mime-type type="video/quicktime"> 
  <comment>QuickTime video</comment> 
  <magic priority="50"> 
  </magic> 
  <glob pattern="*.mov"/> 
</mime-type> 

The attached patch fixes that.
Comment 1 Marius Vollmer 2009-05-11 07:35:43 UTC
This is with shared-mime-info 0.30, forgot to say.
Comment 2 Bastien Nocera 2009-05-11 08:06:13 UTC
The latest version is 0.60, and it's even newer in CVS. Could you check whether that's still needed?
Comment 3 Marius Vollmer 2009-05-11 09:05:24 UTC
(In reply to comment #2)
> The latest version is 0.60, and it's even newer in CVS. Could you check whether
> that's still needed?

From reading the code, it is still needed in 0.60 and CVS.

(I.e., write_match still access match->magic whithout checking whether it is NULL, but I didn't check whether there is some other change that makes sure write_match never sees a NULL.)
Comment 4 Bastien Nocera 2010-12-01 09:15:33 UTC
Already fixed as part of bug 28527, along with a test case.

*** This bug has been marked as a duplicate of bug 28527 ***

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.