Bug 362740 - Websocket D13 close handling is off [autobahn]

+ Address autobahn 0.4.3 test cases 7.9.*
  Description: Send close with invalid close code (999. 1004, 1005, 1006, 1011, 1100, 2000, 2999, 5000, 65535)
  Expectation: Clean close with protocol error code
This commit is contained in:
Joakim Erdfelt 2011-11-02 20:04:03 -07:00
parent da60996ce5
commit c1d681551b
1 changed files with 13 additions and 0 deletions

View File

@ -747,6 +747,19 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc
if (buffer.length()>=2)
{
code=(0xff&buffer.array()[buffer.getIndex()])*0x100+(0xff&buffer.array()[buffer.getIndex()+1]);
// Validate close status codes.
if (code < WebSocketConnectionD13.CLOSE_NORMAL ||
code == WebSocketConnectionD13.CLOSE_UNDEFINED ||
code == WebSocketConnectionD13.CLOSE_NO_CLOSE ||
code == WebSocketConnectionD13.CLOSE_NO_CODE ||
( code > 1010 && code <= 2999 ) ||
code >= 5000 )
{
errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Invalid close control status code " + code);
return;
}
if (buffer.length()>2)
{
if(_utf8.append(buffer.array(),buffer.getIndex()+2,buffer.length()-2,_connection.getMaxTextMessageSize()))