]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
io: use case insensitive check for Connection & Upgrade websock headers
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 6 Sep 2017 13:49:41 +0000 (14:49 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 4 Oct 2017 12:21:53 +0000 (13:21 +0100)
When checking the value of the Connection and Upgrade HTTP headers
the websock RFC (6455) requires the comparison to be case insensitive.
The Connection value should be an exact match not a substring.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
io/channel-websock.c

index 6ddcec1549dcf707169805bc424bf7d1a5d18601..2258557a215122387cfc9caad7541576ca39106e 100644 (file)
@@ -431,12 +431,12 @@ static void qio_channel_websock_handshake_process(QIOChannelWebsock *ioc,
         goto bad_request;
     }
 
-    if (!g_strrstr(connection, QIO_CHANNEL_WEBSOCK_CONNECTION_UPGRADE)) {
+    if (strcasecmp(connection, QIO_CHANNEL_WEBSOCK_CONNECTION_UPGRADE) != 0) {
         error_setg(errp, "No connection upgrade requested '%s'", connection);
         goto bad_request;
     }
 
-    if (!g_str_equal(upgrade, QIO_CHANNEL_WEBSOCK_UPGRADE_WEBSOCKET)) {
+    if (strcasecmp(upgrade, QIO_CHANNEL_WEBSOCK_UPGRADE_WEBSOCKET) != 0) {
         error_setg(errp, "Incorrect upgrade method '%s'", upgrade);
         goto bad_request;
     }