diff options
Diffstat (limited to 'chromium/url')
-rw-r--r-- | chromium/url/gurl.cc | 2 | ||||
-rw-r--r-- | chromium/url/gurl.h | 4 | ||||
-rw-r--r-- | chromium/url/origin.h | 2 | ||||
-rw-r--r-- | chromium/url/run_all_unittests.cc | 1 | ||||
-rw-r--r-- | chromium/url/url_canon.h | 2 | ||||
-rw-r--r-- | chromium/url/url_canon_host.cc | 16 |
6 files changed, 20 insertions, 7 deletions
diff --git a/chromium/url/gurl.cc b/chromium/url/gurl.cc index cec69c7cc49..8ec69021129 100644 --- a/chromium/url/gurl.cc +++ b/chromium/url/gurl.cc @@ -150,7 +150,7 @@ GURL& GURL::operator=(const GURL& other) { return *this; } -GURL& GURL::operator=(GURL&& other) { +GURL& GURL::operator=(GURL&& other) noexcept { spec_ = std::move(other.spec_); is_valid_ = other.is_valid_; parsed_ = other.parsed_; diff --git a/chromium/url/gurl.h b/chromium/url/gurl.h index 96ea8645da6..32ef5de756d 100644 --- a/chromium/url/gurl.h +++ b/chromium/url/gurl.h @@ -78,7 +78,7 @@ class URL_EXPORT GURL { ~GURL(); GURL& operator=(const GURL& other); - GURL& operator=(GURL&& other); + GURL& operator=(GURL&& other) noexcept; // Returns true when this object represents a valid parsed URL. When not // valid, other functions will still succeed, but you will not get canonical @@ -485,6 +485,6 @@ URL_EXPORT bool operator!=(const base::StringPiece& spec, const GURL& x); // variable named |<var_name>|. This helps ensure that the value of |url| gets // preserved in crash dumps. #define DEBUG_ALIAS_FOR_GURL(var_name, url) \ - DEBUG_ALIAS_FOR_CSTR(var_name, url.possibly_invalid_spec().c_str(), 128) + DEBUG_ALIAS_FOR_CSTR(var_name, (url).possibly_invalid_spec().c_str(), 128) #endif // URL_GURL_H_ diff --git a/chromium/url/origin.h b/chromium/url/origin.h index d3ae5f6a7fb..d2bdc6ac2ba 100644 --- a/chromium/url/origin.h +++ b/chromium/url/origin.h @@ -172,7 +172,7 @@ URL_EXPORT bool IsSameOriginWith(const GURL& a, const GURL& b); // stack-allocated variable named |<var_name>|. This helps ensure that the // value of |origin| gets preserved in crash dumps. #define DEBUG_ALIAS_FOR_ORIGIN(var_name, origin) \ - DEBUG_ALIAS_FOR_CSTR(var_name, origin.Serialize().c_str(), 128) + DEBUG_ALIAS_FOR_CSTR(var_name, (origin).Serialize().c_str(), 128) } // namespace url diff --git a/chromium/url/run_all_unittests.cc b/chromium/url/run_all_unittests.cc index 5f577fd35c6..02732cc6613 100644 --- a/chromium/url/run_all_unittests.cc +++ b/chromium/url/run_all_unittests.cc @@ -5,7 +5,6 @@ #include <memory> #include "base/bind.h" -#include "base/message_loop/message_loop.h" #include "base/test/launcher/unit_test_launcher.h" #include "base/test/test_io_thread.h" #include "base/test/test_suite.h" diff --git a/chromium/url/url_canon.h b/chromium/url/url_canon.h index 618ff7b92d8..f779961e3a2 100644 --- a/chromium/url/url_canon.h +++ b/chromium/url/url_canon.h @@ -156,7 +156,7 @@ class RawCanonOutputT : public CanonOutputT<T> { this->buffer_ = fixed_buffer_; this->buffer_len_ = fixed_capacity; } - virtual ~RawCanonOutputT() { + ~RawCanonOutputT() override { if (this->buffer_ != fixed_buffer_) delete[] this->buffer_; } diff --git a/chromium/url/url_canon_host.cc b/chromium/url/url_canon_host.cc index 76a22369b87..9f315477960 100644 --- a/chromium/url/url_canon_host.cc +++ b/chromium/url/url_canon_host.cc @@ -67,6 +67,17 @@ const unsigned char kHostCharLookup[0x80] = { // p q r s t u v w x y z { | } ~ 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',kEsc,kEsc,kEsc, 0 , 0 }; +// RFC1034 maximum FQDN length. +constexpr int kMaxHostLength = 253; + +// Generous padding to account for the fact that UTS#46 normalization can cause +// a long string to actually shrink and fit within the 253 character RFC1034 +// FQDN length limit. Note that this can still be too short for pathological +// cases: An arbitrary number of characters (e.g. U+00AD SOFT HYPHEN) can be +// removed from the input by UTS#46 processing. However, this should be +// sufficient for all normally-encountered, non-abusive hostname strings. +constexpr int kMaxHostBufferLength = kMaxHostLength*5; + const int kTempHostBufferLen = 1024; typedef RawCanonOutputT<char, kTempHostBufferLen> StackBuffer; typedef RawCanonOutputT<base::char16, kTempHostBufferLen> StackBufferW; @@ -159,7 +170,6 @@ bool DoSimpleHost(const INCHAR* host, *has_non_ascii = true; } } - return success; } @@ -172,6 +182,10 @@ bool DoIDNHost(const base::char16* src, int src_len, CanonOutput* output) { RawCanonOutputW<kTempHostBufferLen> url_escaped_host; bool has_non_ascii; DoSimpleHost(src, src_len, &url_escaped_host, &has_non_ascii); + if (url_escaped_host.length() > kMaxHostBufferLength) { + AppendInvalidNarrowString(src, 0, src_len, output); + return false; + } StackBufferW wide_output; if (!IDNToASCII(url_escaped_host.data(), |