From bcf1de5da4d370c83c05428e4a55c20d55975cc6 Mon Sep 17 00:00:00 2001 From: "inferno@chromium.org" Date: Mon, 12 Jul 2010 21:22:12 +0000 Subject: Fixes a crash when xdg_mime library is unable to handle a long file path. BUG=48733 TEST=None Review URL: http://codereview.chromium.org/2980002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52130 0039d316-1c4b-4281-b951-d872f2087c98 --- net/base/mime_util.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'net/base') diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc index 976aab2..5863b68 100644 --- a/net/base/mime_util.cc +++ b/net/base/mime_util.cc @@ -138,6 +138,11 @@ static const char* FindMimeType(const MimeInfo* mappings, bool MimeUtil::GetMimeTypeFromExtension(const FilePath::StringType& ext, string* result) const { + // Avoids crash when unable to handle a long file path. See crbug.com/48733. + const unsigned kMaxFilePathSize = 65536; + if (ext.length() > kMaxFilePathSize) + return false; + // We implement the same algorithm as Mozilla for mapping a file extension to // a mime type. That is, we first check a hard-coded list (that cannot be // overridden), and then if not found there, we defer to the system registry. -- cgit v1.1