[GNOME VFS] mime sniffer crasher bug ...

Michael Meeks <[email protected]>
Newsgroups gmane.comp.gnome.vfs
Organization Ximian.
Message-ID <[email protected]>
Hi Guys,

	The attached (committed) patch fixes #82057. Esentially this file:

[snip]
/home/michael/docs/strategy.txt
/home/michael/docs/#strategy.txt#
[/snip]

	was crashing nautilus & test-mime; ( a bit bad ). I don't quite
understand how this ever worked in fact. The fix possibly needs
back-porting to gnome-vfs 1, can you do that Kjartan ?

	Regards,

		Michael.

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-vfs/ChangeLog,v
retrieving revision 1.1298
diff -u -p -u -r1.1298 ChangeLog
--- ChangeLog	16 May 2002 15:06:00 -0000	1.1298
+++ ChangeLog	17 May 2002 10:53:37 -0000
@@ -1,3 +1,17 @@
+2002-05-17  Michael Meeks  <[email protected]>
+
+	* test/test-mime.c (main): do a debug_shutdown.
+
+	* test/mime-test-files/small-file: add as regression test,
+	causes the crash below.
+
+	* libgnomevfs/gnome-vfs-mime-magic.c
+	(gnome_vfs_mime_try_one_magic_pattern): check vs. the
+	range_end + pattern_length, not the range_start + pattern_length,
+	otherwise for small files eg. 66 bytes and GnomeMagicEntry of
+	nautilus_link ( range_end == 256, pattern_length == 13), we
+	fairly soon segv in try_one_pattern_on_buffer.
+
 2002-05-16  Michael Meeks  <[email protected]>
 
 	* libgnomevfs/gnome-vfs-mime-handlers.c
Index: libgnomevfs/gnome-vfs-mime-magic.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-mime-magic.c,v
retrieving revision 1.38
diff -u -p -u -r1.38 gnome-vfs-mime-magic.c
--- libgnomevfs/gnome-vfs-mime-magic.c	19 Feb 2002 07:46:44 -0000	1.38
+++ libgnomevfs/gnome-vfs-mime-magic.c	17 May 2002 10:53:37 -0000
@@ -521,7 +521,7 @@ gnome_vfs_mime_try_one_magic_pattern (Gn
 	int offset;
 
 	if (sniff_buffer->read_whole_file &&
-	    sniff_buffer->buffer_length < magic_entry->range_start + magic_entry->pattern_length) {
+	    sniff_buffer->buffer_length < magic_entry->range_end + magic_entry->pattern_length) {
 		/* There's no place this pattern could actually match */
 		return FALSE;
 	}
Index: libgnomevfs/gnome-vfs-mime-magic.h
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-mime-magic.h,v
retrieving revision 1.6
diff -u -p -u -r1.6 gnome-vfs-mime-magic.h
--- libgnomevfs/gnome-vfs-mime-magic.h	3 Aug 2001 00:39:58 -0000	1.6
+++ libgnomevfs/gnome-vfs-mime-magic.h	17 May 2002 10:53:37 -0000
@@ -33,11 +33,12 @@ typedef struct _GnomeMagicEntry {
 	char mimetype[48];
 } GnomeMagicEntry;
 
-GnomeMagicEntry *gnome_vfs_mime_magic_parse (const gchar *filename, gint *nents);
+GnomeMagicEntry *gnome_vfs_mime_magic_parse          (const gchar *filename,
+						      gint        *nents);
 
 /* testing calls */
-GnomeMagicEntry *gnome_vfs_mime_test_get_magic_table (const char *table_path);
-void gnome_vfs_mime_dump_magic_table (void);
+GnomeMagicEntry *gnome_vfs_mime_test_get_magic_table (const char  *table_path);
+void             gnome_vfs_mime_dump_magic_table     (void);
 
 G_END_DECLS
 
Index: test/test-mime.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/test/test-mime.c,v
retrieving revision 1.12
diff -u -p -u -r1.12 test-mime.c
--- test/test-mime.c	5 Feb 2002 00:45:13 -0000	1.12
+++ test/test-mime.c	17 May 2002 10:53:38 -0000
@@ -22,7 +22,7 @@
 */
 
 #include <config.h>
-
+#include <bonobo-activation/bonobo-activation.h>
 #include <libgnomevfs/gnome-vfs-init.h>
 #include <libgnomevfs/gnome-vfs-mime-magic.h>
 #include <libgnomevfs/gnome-vfs-mime-utils.h>
@@ -160,5 +160,5 @@ main (int argc, char **argv)
 		gnome_vfs_uri_unref (uri);
 	}
 	
-	return 0;
+	return bonobo_activation_debug_shutdown ();
 }
-- 
 [email protected]  <><, Pseudo Engineer, itinerant idiot


_______________________________________________
gnome-vfs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gnome-vfs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.