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 473611 6c3374416afc7f4d66dc8a33fc55ca693232368b
parent 473610 c8797e136acf3f69a6f9a3c89e9ed6820b002a3e
child 473612 2033284fe125e36b725d450863415ab68d7afb9d
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer, RyanVM
bugs1392739
milestone61.0
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"
 #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);
+}