The XWD magic is too simple--it just matches a single big-endian long
at the beginning of the file. This patch implements a few other
checks. The only thing I'm a bit nervous about is assuming that the
maximum possible bit depth is 32; I've never heard of a higher-depth X
visual, but that doesn't mean one doesn't exist. I also added a MIME
type (image/x-xwindowdump) directive.

This fixes all of the MP3 files mentioned in the original bug report;
if you have any others which exhibit the same problem, please link to
them and I'll see what I can do to tighten up the match. If the patch
needs to be in a different format (a debdiff, or a dpatch against
current git), please let me know and I'll be happy to reformat it, or
tailor it to address any other concerns.

Adam Buchbinder
--- file/magic/Magdir/images	2009-01-29 16:01:53.000000000 -0500
+++ file/magic/Magdir/images	2009-02-14 22:43:58.000000000 -0500
@@ -307,11 +307,20 @@
 #   As described in /usr/X11R6/include/X11/XWDFile.h
 #   used by the xwd program.
 #   Bradford Castalia, idaeim, 1/01
-4	belong	7			XWD X Window Dump image data
->100	string	>\0			\b, "%s"
->16	belong	x			\b, %dx
->20	belong	x			\b%dx
->12	belong	x			\b%d
+#   updated by Adam Buchbinder, 2/09
+# The following assumes version 7 of the format; the first long is the length
+# of the header, which is at least 25 4-byte longs, and the one at offset 8
+# is a constant which is always either 1 or 2. Offset 12 is the pixmap depth,
+# which is a maximum of 32.
+0	belong	>100
+>8	belong	<3
+>>12	belong	<33
+>>>4	belong	7			XWD X Window Dump image data
+!:mime	image/x-xwindowdump
+>>>>100	string	>\0			\b, "%s"
+>>>>16	belong	x			\b, %dx
+>>>>20	belong	x			\b%dx
+>>>>12	belong	x			\b%d
 
 # PDS - Planetary Data System
 #   These files use Parameter Value Language in the header section.

Reply via email to