Bug 1436809 - Check that stream message was converted to string correctly. r=valentin
authorMichal Novotny <michal.novotny@gmail.com>
Mon, 02 Apr 2018 12:59:18 -0400
changeset 411348 b229809d17ff18263becfad6f9777c9ab0165279
parent 411347 5c643acb826034e57c155860932e868445b444d4
child 411349 53f006fc6afda343190b261833a087c95309cbd9
push id33752
push userdluca@mozilla.com
push dateMon, 02 Apr 2018 22:00:32 +0000
treeherdermozilla-central@445255800255 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1436809
milestone61.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 1436809 - Check that stream message was converted to string correctly. r=valentin
netwerk/protocol/websocket/WebSocketChannel.cpp
--- a/netwerk/protocol/websocket/WebSocketChannel.cpp
+++ b/netwerk/protocol/websocket/WebSocketChannel.cpp
@@ -1047,16 +1047,19 @@ public:
   nsresult ConvertStreamToString()
   {
     MOZ_ASSERT(mMsgType == kMsgTypeStream, "Not a stream!");
 
     nsAutoPtr<nsCString> temp(new nsCString());
     nsresult rv = NS_ReadInputStreamToString(mMsg.pStream, *temp, mLength);
 
     NS_ENSURE_SUCCESS(rv, rv);
+    if (temp->Length() != mLength) {
+      return NS_ERROR_UNEXPECTED;
+    }
 
     mMsg.pStream->Close();
     mMsg.pStream->Release();
     mMsg.pString.mValue = temp.forget();
     mMsg.pString.mOrigValue = nullptr;
     mMsgType = kMsgTypeBinaryString;
 
     return NS_OK;