bug 675919 - websockets fail connection on unknown control code. r=jduell
authorPatrick McManus <mcmanus@ducksong.com>
Thu, 04 Aug 2011 22:45:55 -0700
changeset 73894 cd0106ceb8ce337636875ef7b1f0d143cb33b7a4
parent 73893 840fd3069d1fecb1a7aeed20544dd26411d2ffcb
child 73895 1d186a5f3a96e938a253726ac48ecaf00e80c712
push id20923
push usermak77@bonardo.net
push dateFri, 05 Aug 2011 15:10:34 +0000
treeherdermozilla-central@c7931e07dd4d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjduell
bugs675919
milestone8.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 675919 - websockets fail connection on unknown control code. r=jduell
netwerk/protocol/websocket/WebSocketChannel.cpp
--- a/netwerk/protocol/websocket/WebSocketChannel.cpp
+++ b/netwerk/protocol/websocket/WebSocketChannel.cpp
@@ -911,20 +911,25 @@ WebSocketChannel::ProcessInput(PRUint8 *
             new CallOnServerClose(mListener, mContext,
                                   mServerCloseCode, mServerCloseReason));
 
         if (mClientClosed)
           ReleaseSession();
       } else if (opcode == kPing) {
         LOG(("WebSocketChannel:: ping received\n"));
         GeneratePong(payload, payloadLength);
-      } else {
+      } else if (opcode == kPong) {
         // opcode kPong: the mere act of receiving the packet is all we need
         // to do for the pong to trigger the activity timers
         LOG(("WebSocketChannel:: pong received\n"));
+      } else {
+        /* unknown control frame opcode */
+        LOG(("WebSocketChannel:: unknown control op code %d\n", opcode));
+        AbortSession(NS_ERROR_ILLEGAL_VALUE);
+        return NS_ERROR_ILLEGAL_VALUE;
       }
 
       if (mFragmentAccumulator) {
         // Remove the control frame from the stream so we have a contiguous
         // data buffer of reassembled fragments
         LOG(("WebSocketChannel:: Removing Control From Read buffer\n"));
         NS_ABORT_IF_FALSE(mFramePtr + framingLength == payload,
                           "payload offset from frameptr wrong");