Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Unified Diff: net/base/mime_util.cc

Issue 2980002: Fixes a crash when xdg_mime library is unable to handle a long file path.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/mime_util.cc
===================================================================
--- net/base/mime_util.cc (revision 52038)
+++ net/base/mime_util.cc (working copy)
@@ -138,6 +138,11 @@
bool MimeUtil::GetMimeTypeFromExtension(const FilePath::StringType& ext,
string* result) const {
+ // Fixes a crash when xdg_mime library is unable to handle a long file path.
+ 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.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698