[libsoup] Fix invalid UTF8 close payload



commit 03c600632656500723cabeaa7d188a1c1a31f525
Author: Italo Guerrieri <guerital amazon it>
Date:   Thu Dec 28 12:14:55 2017 +0100

    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

 libsoup/soup-websocket-connection.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/libsoup/soup-websocket-connection.c b/libsoup/soup-websocket-connection.c
index f381256..25a87b5 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 */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]