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

Unified Diff: net/base/mime_sniffer.cc

Issue 612413002: Do not read past the end of the string in net::SniffXML(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix condition Created 6 years, 3 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_sniffer.cc
diff --git a/net/base/mime_sniffer.cc b/net/base/mime_sniffer.cc
index ef2e27030bb5f642477362def29a683e5ad3a544..61ef948211059db1857f10df3cf5b9386a7eaaf3 100644
--- a/net/base/mime_sniffer.cc
+++ b/net/base/mime_sniffer.cc
@@ -612,12 +612,14 @@ static bool SniffXML(const char* content,
if (!pos)
return false;
- if (base::strncasecmp(pos, "<?xml", sizeof("<?xml") - 1) == 0) {
+ if ((pos + sizeof("<?xml") - 1 <= end) &&
+ (base::strncasecmp(pos, "<?xml", sizeof("<?xml") - 1) == 0)) {
// Skip XML declarations.
++pos;
continue;
- } else if (base::strncasecmp(pos, "<!DOCTYPE",
- sizeof("<!DOCTYPE") - 1) == 0) {
+ } else if ((pos + sizeof("<!DOCTYPE") - 1 <= end) &&
+ (base::strncasecmp(pos, "<!DOCTYPE", sizeof("<!DOCTYPE") - 1) ==
+ 0)) {
// Skip DOCTYPE declarations.
++pos;
continue;
« 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