The mime identification could potentially get a bad length exception while processing garbled "file" output
This commit is contained in:
parent
56fe54412f
commit
e8f63ec124
@ -74,6 +74,11 @@ static string mimetypefromdata(const string &fn, bool usfc)
|
|||||||
// The result of 'file' execution begins with the file name
|
// The result of 'file' execution begins with the file name
|
||||||
// which may contain spaces. We happen to know its size, so
|
// which may contain spaces. We happen to know its size, so
|
||||||
// strip it:
|
// 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());
|
result = result.substr(fn.size());
|
||||||
// Now looks like ": text/plain; charset=us-ascii"
|
// Now looks like ": text/plain; charset=us-ascii"
|
||||||
// Split it, and take second field
|
// Split it, and take second field
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user