From nobody Thu Nov 6 17:04:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 148822993467253.179720774863085; Mon, 27 Feb 2017 13:12:14 -0800 (PST) Received: from localhost ([::1]:56889 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciSab-0002Tm-2Q for importer@patchew.org; Mon, 27 Feb 2017 16:12:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58556) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciRhG-0003v5-JB for qemu-devel@nongnu.org; Mon, 27 Feb 2017 15:15:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciRhF-0004VE-ST for qemu-devel@nongnu.org; Mon, 27 Feb 2017 15:15:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47844) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciRhF-0004V5-N4 for qemu-devel@nongnu.org; Mon, 27 Feb 2017 15:15:01 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D8DA83A7691; Mon, 27 Feb 2017 20:15:01 +0000 (UTC) Received: from t460.redhat.com (ovpn-116-127.ams2.redhat.com [10.36.116.127]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RKExGB028763; Mon, 27 Feb 2017 15:15:00 -0500 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 20:14:56 +0000 Message-Id: <20170227201456.31814-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 27 Feb 2017 20:15:01 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] io: ignore case when matching websockets HTTP headers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Denis V. Lunev" , Anton Nefedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" According to RFC7230 Section 3.2, header field name is case-insensitive. Convert the header data into all lowercase before doing string matching on the headers. Signed-off-by: Daniel P. Berrange Reviewed-by: Denis V. Lunev --- io/channel-websock.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/io/channel-websock.c b/io/channel-websock.c index a06a4a8..32b7f37 100644 --- a/io/channel-websock.c +++ b/io/channel-websock.c @@ -33,9 +33,9 @@ #define QIO_CHANNEL_WEBSOCK_GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" #define QIO_CHANNEL_WEBSOCK_GUID_LEN strlen(QIO_CHANNEL_WEBSOCK_GUID) =20 -#define QIO_CHANNEL_WEBSOCK_HEADER_PROTOCOL "Sec-WebSocket-Protocol" -#define QIO_CHANNEL_WEBSOCK_HEADER_VERSION "Sec-WebSocket-Version" -#define QIO_CHANNEL_WEBSOCK_HEADER_KEY "Sec-WebSocket-Key" +#define QIO_CHANNEL_WEBSOCK_HEADER_PROTOCOL "sec-websocket-protocol" +#define QIO_CHANNEL_WEBSOCK_HEADER_VERSION "sec-websocket-version" +#define QIO_CHANNEL_WEBSOCK_HEADER_KEY "sec-websocket-key" =20 #define QIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY "binary" =20 @@ -223,7 +223,7 @@ static int qio_channel_websock_handshake_process(QIOCha= nnelWebsock *ioc, static int qio_channel_websock_handshake_read(QIOChannelWebsock *ioc, Error **errp) { - char *handshake_end; + char *handshake_end, *tmp; ssize_t ret; /* Typical HTTP headers from novnc are 512 bytes, so limiting * total header size to 4096 is easily enough. */ @@ -249,9 +249,13 @@ static int qio_channel_websock_handshake_read(QIOChann= elWebsock *ioc, } } =20 + for (tmp =3D (char *)ioc->encinput.buffer; tmp < handshake_end; tmp++)= { + *tmp =3D g_ascii_tolower(*tmp); + } + if (qio_channel_websock_handshake_process(ioc, (char *)ioc->encinput.buffer, - ioc->encinput.offset, + handshake_end - (char *)ioc-= >encinput.buffer, errp) < 0) { return -1; } --=20 2.9.3