Bug 1392739 - Add test for faulty nsStandardURL deserialization. r=mayhemer, a=RyanVM
authorAlex Gaynor <agaynor@mozilla.com>
Wed, 23 May 2018 22:25:08 +0200
changeset 805995 f1465ba4ff3aacbf5adcab0becde3838955c6a3f
parent 805994 5e8ae758ac7f589ec09f67b072cc49d44877046b
child 805996 25a710304ebbe1607fa94a94fcea921675058d39
push id112832
push userbballo@mozilla.com
push dateFri, 08 Jun 2018 21:11:22 +0000
reviewersmayhemer, RyanVM
bugs1392739
milestone60.0.2
Bug 1392739 - Add test for faulty nsStandardURL deserialization. r=mayhemer, a=RyanVM
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"
 #define protected public // hack to access setter methods
 #include "../../base/nsStandardURL.h"
 #undef protected
 using mozilla::net::nsStandardURL;
 
 // In nsStandardURL.cpp
 extern nsresult Test_NormalizeIPv4(const nsACString& host, nsCString& result);
 
@@ -264,8 +266,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);
+}