Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1589)

Unified Diff: runtime/bin/websocket_impl.dart

Issue 10946007: Never send reserved status codes in a close frame (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/websocket.dart ('k') | tests/standalone/io/web_socket_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/websocket_impl.dart
diff --git a/runtime/bin/websocket_impl.dart b/runtime/bin/websocket_impl.dart
index 0e187a80b5b4548a641b2235b0f09353623f1fe5..27fad8168b06552888e7b028a9a2b54e38998421 100644
--- a/runtime/bin/websocket_impl.dart
+++ b/runtime/bin/websocket_impl.dart
@@ -289,6 +289,9 @@ class _WebSocketProtocolProcessor {
throw new WebSocketException("Protocol error");
}
status = _controlPayload[0] << 8 | _controlPayload[1];
+ if (status == WebSocketStatus.NO_STATUS_RECEIVED) {
+ throw new WebSocketException("Protocol error");
+ }
if (_controlPayload.length > 2) {
var decoder = _StringDecoders.decoder(Encoding.UTF_8);
decoder.write(
@@ -423,6 +426,12 @@ class _WebSocketConnectionBase {
}
close([int status, String reason]) {
+ if (status == WebSocketStatus.RESERVED_1004 ||
+ status == WebSocketStatus.NO_STATUS_RECEIVED ||
+ status == WebSocketStatus.RESERVED_1015) {
+ throw new WebSocketException("Reserved status code $status");
+ }
+
if (_closeSent) return;
List<int> data;
if (status !== null) {
@@ -506,7 +515,11 @@ class _WebSocketConnectionBase {
if (_closeTimer !== null) _closeTimer.cancel();
_socket.close();
} else {
- close(status);
+ if (status != WebSocketStatus.NO_STATUS_RECEIVED) {
+ close(status);
+ } else {
+ close();
+ }
}
}
« no previous file with comments | « runtime/bin/websocket.dart ('k') | tests/standalone/io/web_socket_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698