Bug 1436809 - Check that stream message was converted to string correctly. r=valentin, a=abillings
authorMichal Novotny <michal.novotny@gmail.com>
Mon, 02 Apr 2018 12:59:18 -0400
changeset 460497 8cf59abf9839e37785604c762c05d8db1648c166
parent 460496 d8c0fba8b94adbdef6e759885c9d79cb7ae2d2c0
child 460498 23754ad53136c686390597f2ed0228db3013ea21
push id8959
push userryanvm@gmail.com
push dateMon, 02 Apr 2018 17:46:14 +0000
treeherdermozilla-beta@c31d3d320dbd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin, abillings
bugs1436809
milestone60.0
Bug 1436809 - Check that stream message was converted to string correctly. r=valentin, a=abillings
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;