Bug 711205: Limit websocket outbound msg size to PR_INT32_MAX. r=mcmanus
authorJason Duell <jduell.mcbugs@gmail.com>
Tue, 20 Dec 2011 00:20:12 -0800
changeset 84663 384e5cb0ffa6efbb921b15aa6e5ecece975b9572
parent 84662 998eecfec4dec48fa2f279260854a52ae179566d
child 84664 2afd7ae68e8b0ef9e1b56991005f2917a02022c3
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs711205
milestone11.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 711205: Limit websocket outbound msg size to PR_INT32_MAX. r=mcmanus
netwerk/protocol/websocket/WebSocketChannel.cpp
--- a/netwerk/protocol/websocket/WebSocketChannel.cpp
+++ b/netwerk/protocol/websocket/WebSocketChannel.cpp
@@ -2368,16 +2368,21 @@ WebSocketChannel::SendMsgCommon(const ns
     return NS_ERROR_UNEXPECTED;
   }
 
   if (mStopped) {
     LOG(("WebSocketChannel:: Error: send when stopped\n"));
     return NS_ERROR_NOT_CONNECTED;
   }
 
+  if (aLength > mMaxMessageSize) {
+    LOG(("WebSocketChannel:: Error: message too big\n"));
+    return NS_ERROR_FILE_TOO_BIG;
+  }
+
   return mSocketThread->Dispatch(
     aStream ? new OutboundEnqueuer(this, new OutboundMessage(aStream, aLength))
             : new OutboundEnqueuer(this,
                      new OutboundMessage(aIsBinary ? kMsgTypeBinaryString
                                                    : kMsgTypeString,
                                          new nsCString(*aMsg))),
     nsIEventTarget::DISPATCH_NORMAL);
 }