Bug 1392739 - Add test for faulty nsStandardURL deserialization. r=mayhemer
authorAlex Gaynor <agaynor@mozilla.com>
Wed, 23 May 2018 22:25:08 +0200
changeset 421041 f72ceb91e620b9b95806132fe9ca3687fab49b68
parent 421040 5c47f8a1bad20a61a1ec699cc6508e21f39a7a98
child 421042 4cc60824e00d29a34537e081a7a150b9d05710da
child 421238 3aaea88740602dbb570cec5df348beff7abf1842
push id103975
push userryanvm@gmail.com
push dateMon, 04 Jun 2018 13:13:24 +0000
treeherdermozilla-inbound@f72ceb91e620 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1392739
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1392739 - Add test for faulty nsStandardURL deserialization. r=mayhemer
netwerk/test/gtest/TestStandardURL.cpp
--- a/netwerk/test/gtest/TestStandardURL.cpp
+++ b/netwerk/test/gtest/TestStandardURL.cpp
@@ -1,18 +1,20 @@
 #include "gtest/gtest.h"
 #include "gtest/MozGTestBench.h" // For MOZ_GTEST_BENCH
 
 #include "nsCOMPtr.h"
 #include "nsNetCID.h"
 #include "nsIURL.h"
+#include "nsIStandardURL.h"
 #include "nsString.h"
 #include "nsPrintfCString.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIURIMutator.h"
+#include "mozilla/ipc/URIUtils.h"
 #include "mozilla/Unused.h"
 
 // In nsStandardURL.cpp
 extern nsresult Test_NormalizeIPv4(const nsACString& host, nsCString& result);
 
 
 TEST(TestStandardURL, Simple) {
     nsCOMPtr<nsIURI> url;
@@ -269,8 +271,21 @@ TEST(TestStandardURL, Mutator)
   nsCOMPtr<nsIURL> url;
   rv = NS_MutateURI(uri)
          .SetScheme(NS_LITERAL_CSTRING("https"))
          .Finalize(url);
   ASSERT_EQ(rv, NS_OK);
   ASSERT_EQ(url->GetSpec(out), NS_OK);
   ASSERT_TRUE(out == NS_LITERAL_CSTRING("https://mozilla.org/path?query#ref"));
 }
+
+TEST(TestStandardURL, Deserialize_Bug1392739)
+{
+  mozilla::ipc::StandardURLParams standard_params;
+  standard_params.urlType() = nsIStandardURL::URLTYPE_STANDARD;
+  standard_params.spec() = NS_LITERAL_CSTRING("");
+  standard_params.host() = mozilla::ipc::StandardURLSegment(4294967295, 1);
+
+  mozilla::ipc::URIParams params(standard_params);
+
+  nsCOMPtr<nsIURIMutator> mutator = do_CreateInstance(NS_STANDARDURLMUTATOR_CID);
+  ASSERT_EQ(mutator->Deserialize(params), NS_ERROR_FAILURE);
+}