The mime identification could potentially get a bad length exception while processing garbled "file" output

This commit is contained in:
Jean-Francois Dockes 2011-10-13 16:38:26 +02:00
parent 56fe54412f
commit e8f63ec124

View File

@ -74,6 +74,11 @@ static string mimetypefromdata(const string &fn, bool usfc)
// The result of 'file' execution begins with the file name
// which may contain spaces. We happen to know its size, so
// strip it:
if (result.size() <= fn.size()) {
// Garbage "file" output. Maybe the result of a charset
// conversion attempt?
return string();
}
result = result.substr(fn.size());
// Now looks like ": text/plain; charset=us-ascii"
// Split it, and take second field