|
|
9bac43 |
From 16063b60ae69a93169ab06265dc597072d9bd8ed Mon Sep 17 00:00:00 2001
|
|
|
9bac43 |
From: "Daniel P. Berrange" <berrange@redhat.com>
|
|
|
9bac43 |
Date: Wed, 20 Dec 2017 17:56:59 +0100
|
|
|
9bac43 |
Subject: [PATCH 19/42] io: cope with websock 'Connection' header having
|
|
|
9bac43 |
multiple values
|
|
|
9bac43 |
|
|
|
9bac43 |
RH-Author: Daniel P. Berrange <berrange@redhat.com>
|
|
|
9bac43 |
Message-id: <20171220175702.29663-18-berrange@redhat.com>
|
|
|
9bac43 |
Patchwork-id: 78470
|
|
|
9bac43 |
O-Subject: [RHV-7.5 qemu-kvm-rhev PATCH v2 17/20] io: cope with websock 'Connection' header having multiple values
|
|
|
9bac43 |
Bugzilla: 1518649
|
|
|
9bac43 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
The noVNC server sends a header "Connection: keep-alive, Upgrade" which
|
|
|
9bac43 |
fails our simple equality test. Split the header on ',', trim whitespace
|
|
|
9bac43 |
and then check for 'upgrade' token.
|
|
|
9bac43 |
|
|
|
9bac43 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
9bac43 |
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
9bac43 |
(cherry picked from commit 6d5d23b00709510d55711661c7ca41408fd9934e)
|
|
|
9bac43 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9bac43 |
---
|
|
|
9bac43 |
io/channel-websock.c | 14 +++++++++++++-
|
|
|
9bac43 |
1 file changed, 13 insertions(+), 1 deletion(-)
|
|
|
9bac43 |
|
|
|
9bac43 |
diff --git a/io/channel-websock.c b/io/channel-websock.c
|
|
|
9bac43 |
index e82b1be..0354845 100644
|
|
|
9bac43 |
--- a/io/channel-websock.c
|
|
|
9bac43 |
+++ b/io/channel-websock.c
|
|
|
9bac43 |
@@ -374,6 +374,9 @@ static void qio_channel_websock_handshake_process(QIOChannelWebsock *ioc,
|
|
|
9bac43 |
size_t nhdrs = G_N_ELEMENTS(hdrs);
|
|
|
9bac43 |
const char *protocols = NULL, *version = NULL, *key = NULL,
|
|
|
9bac43 |
*host = NULL, *connection = NULL, *upgrade = NULL;
|
|
|
9bac43 |
+ char **connectionv;
|
|
|
9bac43 |
+ bool upgraded = false;
|
|
|
9bac43 |
+ size_t i;
|
|
|
9bac43 |
|
|
|
9bac43 |
nhdrs = qio_channel_websock_extract_headers(ioc, buffer, hdrs, nhdrs, errp);
|
|
|
9bac43 |
if (!nhdrs) {
|
|
|
9bac43 |
@@ -440,7 +443,16 @@ static void qio_channel_websock_handshake_process(QIOChannelWebsock *ioc,
|
|
|
9bac43 |
goto bad_request;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
- if (strcasecmp(connection, QIO_CHANNEL_WEBSOCK_CONNECTION_UPGRADE) != 0) {
|
|
|
9bac43 |
+ connectionv = g_strsplit(connection, ",", 0);
|
|
|
9bac43 |
+ for (i = 0; connectionv != NULL && connectionv[i] != NULL; i++) {
|
|
|
9bac43 |
+ g_strstrip(connectionv[i]);
|
|
|
9bac43 |
+ if (strcasecmp(connectionv[i],
|
|
|
9bac43 |
+ QIO_CHANNEL_WEBSOCK_CONNECTION_UPGRADE) == 0) {
|
|
|
9bac43 |
+ upgraded = true;
|
|
|
9bac43 |
+ }
|
|
|
9bac43 |
+ }
|
|
|
9bac43 |
+ g_strfreev(connectionv);
|
|
|
9bac43 |
+ if (!upgraded) {
|
|
|
9bac43 |
error_setg(errp, "No connection upgrade requested '%s'", connection);
|
|
|
9bac43 |
goto bad_request;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
--
|
|
|
9bac43 |
1.8.3.1
|
|
|
9bac43 |
|