Commit 03667569 authored by Italo Guerrieri's avatar Italo Guerrieri Committed by Ignacio Casal Quinteiro
Browse files

Fix invalid close code

Close the connection with a protocol error, if a close control
uses a code reserved for future implementations of the WebSocket
protocol.
Fix Autobahn test cases 7.9.*.

https://bugzilla.gnome.org/show_bug.cgi?id=792113
parent e7c827d5
......@@ -578,7 +578,11 @@ close_connection (SoupWebsocketConnection *self,
}
break;
default:
g_debug ("Wrong closing code %d received", code);
if (code < 3000) {
g_debug ("Wrong closing code %d received", code);
protocol_error_and_close (self);
return;
}
}
g_signal_emit (self, signals[CLOSING], 0);
......@@ -605,10 +609,21 @@ receive_close (SoupWebsocketConnection *self,
pv->peer_close_data = NULL;
pv->close_received = TRUE;
/* Store the code/data payload */
if (len >= 2) {
switch (len) {
case 0:
/* Send a clean close when having an empty payload */
close_connection (self, 1000, NULL);
return;
case 1:
/* Send a protocol error since the close code is incomplete */
protocol_error_and_close (self);
return;
default:
/* Store the code/data payload */
pv->peer_close_code = (guint16)data[0] << 8 | data[1];
break;
}
if (len > 2) {
data += 2;
len -= 2;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment