crash on invalid UTF-8 in autorun.inf file
(This has originally been filed as a PCRE1 bug at https://bugs.exim.org/show_bug.cgi?id=2330 but is actually a bug in gvfs, not pcre/glib.)
In common/gvfsmountinfo.c there is this code:
/* Scan through for an "icon=" line. Can't use GKeyFile,
* because .inf files aren't always valid key files
**/
[...]
icon_regex = g_regex_new ("icon\\s*=\\s*+([^,\\r\\n]+)",
G_REGEX_CASELESS, 0, NULL);
g_regex_match (icon_regex, content, 0,
&match_info);
When you create a autorun.inf file like this, for example:
$ printf 'icon\xfa=' > autorun.inf
and then put that file on a medium where gvfs will try to read it, you'll get a crash (or at the very least an invalid memory read).
This is due to the file contents not being valid UTF-8. There is code further down to check that the extracted icon filename is UTF-8, but that's too late: g_regex_match() requires UTF-8 input.
The fix is simple: add G_REGEX_RAW to the compile flags in the g_regex_new():
regex = g_regex_new("...", G_REGEX_CASELESS | G_REGEX_RAW, ....)