Bug 1412313 - Handle large string lengths in nsAString's ParamTraits. r=billm
authorAlex Gaynor <agaynor@mozilla.com>
Fri, 27 Oct 2017 16:13:46 -0400
changeset 442416 7cc3c1afc8ce8eee7879e2b194eae2643b35a7b6
parent 442415 c6a6606f3ea7a662ac7f0384d4d2b67d447e348a
child 442417 083a9c84fbd09a6ff9bfecabbf773650842fe1c0
child 442482 a7ee9c35934a0b43fe9f2ec5f0bf006815d1fcef
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1412313
milestone58.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 1412313 - Handle large string lengths in nsAString's ParamTraits. r=billm MozReview-Commit-ID: HR6kMzSkewS
ipc/glue/IPCMessageUtils.h
--- a/ipc/glue/IPCMessageUtils.h
+++ b/ipc/glue/IPCMessageUtils.h
@@ -421,19 +421,25 @@ struct ParamTraits<nsAString>
       aResult->SetIsVoid(true);
       return true;
     }
 
     uint32_t length;
     if (!ReadParam(aMsg, aIter, &length)) {
       return false;
     }
+
     aResult->SetLength(length);
 
-    return aMsg->ReadBytesInto(aIter, aResult->BeginWriting(), length * sizeof(char16_t));
+    mozilla::CheckedInt<uint32_t> byteLength = mozilla::CheckedInt<uint32_t>(length) * sizeof(char16_t);
+    if (!byteLength.isValid()) {
+      return false;
+    }
+
+    return aMsg->ReadBytesInto(aIter, aResult->BeginWriting(), byteLength.value());
   }
 
   static void Log(const paramType& aParam, std::wstring* aLog)
   {
     if (aParam.IsVoid())
       aLog->append(L"(NULL)");
     else {
 #ifdef WCHAR_T_IS_UTF16