From patchwork Fri Aug 19 15:39:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 598507 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1502438mae; Fri, 19 Aug 2022 08:47:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR7GR2n53SxpbS+bZZHqJI9QwQrbIFt+iHpjESk1kq+63lGwJSj7pSRTFgtzI8KjQPLsKbci X-Received: by 2002:a05:6214:5093:b0:477:4dce:80af with SMTP id kk19-20020a056214509300b004774dce80afmr6968974qvb.69.1660924075046; Fri, 19 Aug 2022 08:47:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660924075; cv=none; d=google.com; s=arc-20160816; b=MLOeCN9pFAlK07mQU+57iCohcAkj8gxEz04bU0nT99NCVdhjbCrkxiU40mb7hP3oJ4 hb/3uJ3Dlmt2XMmqKwVFIA2X79RLVkuy164u57HZ3DQPaIhbM/Tlff6FVMdSvT0atSSD YrHQlgQak1b9G7AxbhhWrW9C+eRiRrWAfcD1SV1KWt8hdcBR5Lmz1gfSuLcTsXeuf9dy 6TzgF29J787vwGf29iGqqkQ+QmzdBPGn5jThy2iuvHJwinE14z6g4FFUT4ycHA4a2kxL FN+CejKjXIh5yCD+gB+xtV3NyiPLl8121/NipHJyTJcXELDfYoqs1bt5ksRCn88ZvW0x JUlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Zg9fu5qHwdrrZhY9h0fcERwtTu8sDUqtYMAjp6fh9AE=; b=RqPzfdq6WbQL8w/g4Nb0iXfaCJzrQkSH99YDEDUV6+Lo/zw1wi/q1MgIPqr/h17Lt9 3NZFr6etgAueHS8lFsMaQmu9mjbzEp8fD59bY1roLNiBKQlnOV2wT1c88Uq/RhBgdSPj /xpu0QplDBiNla/pBcwq4TWmtOhbUjGaDdxbuOlNNpyYYPdSV+hE1EjSoGAgU9lycjEX QbHY9+M08j6lz0w4GCJyBXJ7tIrWQ/gyOC+3NSRxBxdmvvuLhdhrj5QGcIO6lkGlDuIv 0GUYhdcvrDadNsPlNDbv7Rjj/2knohoQHCugQr58sMBFS5v5OHhWnAJZHaP/0LNk6mZu CiOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="gVjmmY/h"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y25-20020a37f619000000b006bac73a0feasi1976119qkj.466.2022.08.19.08.47.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Aug 2022 08:47:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="gVjmmY/h"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP4Dy-0000qk-Gk for patch@linaro.org; Fri, 19 Aug 2022 11:47:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP468-0005fH-L4 for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:48 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:40745) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP463-00064H-IW for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:48 -0400 Received: by mail-wr1-x42d.google.com with SMTP id h5so4808899wru.7 for ; Fri, 19 Aug 2022 08:39:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=Zg9fu5qHwdrrZhY9h0fcERwtTu8sDUqtYMAjp6fh9AE=; b=gVjmmY/hxoqNMWTlk4nX/AeiWWNR626hHESiulMtw709ydBi4zvE+eZZ9EAP45cWgD C0GGnbzJOXYEN9icePhlG73AzCvExVZhHKbDh5b3FOwfhaN9whwWpvRd4Q0+qy8pn/Vb XPo/EqIblD0LOqw2HiCxSWmj+F+5NCRhZaNmf1XI+LAQpFFf9vOlihCSQqgaCR+jsMce dVQstpq44+mX7D4o0IuUWwSucL3GJOreLTWzl4Ya4a9DjxSxk0y9cIiSTLodUVrKwbIO O82pzxKNBe78L36vrQ2JUkCvNKsVtVIX7+tU7hCXaeIhPcEPXMZJRF7hzkaf8kZECil6 464Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=Zg9fu5qHwdrrZhY9h0fcERwtTu8sDUqtYMAjp6fh9AE=; b=JiBXT1tcV6Ac5D+dpHCFe9TvhxB2Phq1ujXc5wswKGoLliaes4o8dvsmfA/L3lF8VR 3vOV/8iCdjjx4lfEP6zDUIteuEaUQ51ZtxVYB0fyCugURm/geBrY8A5aJm9UDg5rrHAA sjmZejmnPkDebCn9At1DWDTrhlq7IC2VmW7+TfHwGhcXXsMa1TziNd2vE7Cc3yLQysc9 JL5OLkmc0F3DR5ISuIt0me64KWeNTNCXJ4wxpsJzdue+x2CKShfy42AiO29h9mGZ46YE M5L+W/gNPolKsfW65xEUNEVAMHrTI7aHtepCIYl9vOONf9iIF7MQvfhazojRq8N2lXXB v0Eg== X-Gm-Message-State: ACgBeo0efClFe1goHFqPrrT7dFGe/QM11IMT1X+AI3y+Y2XBVAl60JZl z4UHBjnTUqDUaqIVlvPpTB5vWT4k8WmqEA== X-Received: by 2002:adf:f18d:0:b0:225:3a78:cef0 with SMTP id h13-20020adff18d000000b002253a78cef0mr1933636wro.578.1660923580049; Fri, 19 Aug 2022 08:39:40 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id bi13-20020a05600c3d8d00b003a54109a6a0sm5558396wmb.3.2022.08.19.08.39.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 08:39:39 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Samuel Thibault , =?utf-8?q?Marc-Andr=C3=A9_L?= =?utf-8?q?ureau?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Daniel Henrique Barboza , David Gibson , Greg Kurz , Dmitry Fleytman , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org Subject: [PATCH v2 04/11] io/channel-websock: Replace strlen(const_str) by sizeof(const_str) - 1 Date: Fri, 19 Aug 2022 16:39:24 +0100 Message-Id: <20220819153931.3147384-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220819153931.3147384-1-peter.maydell@linaro.org> References: <20220819153931.3147384-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé The combined_key[... QIO_CHANNEL_WEBSOCK_GUID_LEN ...] array in qio_channel_websock_handshake_send_res_ok() expands to a call to strlen(QIO_CHANNEL_WEBSOCK_GUID), and the compiler doesn't realize the string is const, so consider combined_key[] being a variable-length array. To remove the variable-length array, we provide it a hint to the compiler by using sizeof() - 1 instead of strlen(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- io/channel-websock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io/channel-websock.c b/io/channel-websock.c index 9619906ac36..fb4932ade70 100644 --- a/io/channel-websock.c +++ b/io/channel-websock.c @@ -32,7 +32,7 @@ #define QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN 24 #define QIO_CHANNEL_WEBSOCK_GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" -#define QIO_CHANNEL_WEBSOCK_GUID_LEN strlen(QIO_CHANNEL_WEBSOCK_GUID) +#define QIO_CHANNEL_WEBSOCK_GUID_LEN (sizeof(QIO_CHANNEL_WEBSOCK_GUID) - 1) #define QIO_CHANNEL_WEBSOCK_HEADER_PROTOCOL "sec-websocket-protocol" #define QIO_CHANNEL_WEBSOCK_HEADER_VERSION "sec-websocket-version"