summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorItalo Guerrieri <guerital@amazon.it>2017-12-28 12:14:55 +0100
committerIgnacio Casal Quinteiro <qignacio@amazon.com>2018-01-10 22:11:39 +0100
commit03c600632656500723cabeaa7d188a1c1a31f525 (patch)
treef0c18a6d220fede691ae28df5d4116edb236bb73
parent5dec678b276c5e378a530599f021d8a39e28dd8b (diff)
downloadlibsoup-03c600632656500723cabeaa7d188a1c1a31f525.tar.gz
Fix invalid UTF8 close payload
Close the connection with a protocol error if the close payload is an invalid utf8. Fix Autobahn test case 7.5.1. https://bugzilla.gnome.org/show_bug.cgi?id=792113
-rw-r--r--libsoup/soup-websocket-connection.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libsoup/soup-websocket-connection.c b/libsoup/soup-websocket-connection.c
index f3812563..25a87b55 100644
--- a/libsoup/soup-websocket-connection.c
+++ b/libsoup/soup-websocket-connection.c
@@ -611,10 +611,14 @@ receive_close (SoupWebsocketConnection *self,
if (len > 2) {
data += 2;
len -= 2;
- if (g_utf8_validate ((char *)data, len, NULL))
- pv->peer_close_data = g_strndup ((char *)data, len);
- else
+
+ if (!g_utf8_validate ((char *)data, len, NULL)) {
g_debug ("received non-UTF8 close data: %d '%.*s' %d", (int)len, (int)len, (char *)data, (int)data[0]);
+ protocol_error_and_close (self);
+ return;
+ }
+
+ pv->peer_close_data = g_strndup ((char *)data, len);
}
/* Once we receive close response on server, close immediately */