From nobody Mon May 13 09:10:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1668496845; cv=none; d=zohomail.com; s=zohoarc; b=L02stH6sGO2TGRjgaVJc1Z/gMPlpUuQuWtMB0o4k4bObKVkuDkS/ziLcseL1zRKL577KhdTGU2Pm+gawApQaKPwavK9UjIGAwVRQGqBjLbkn1csM2gq4NLhXmR/5idneepoYJ4xrM47yS+FIwNXAMw4L1b5O7bXz14EPjJz1DUA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668496845; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=5VWGggTvJIH/VEXlpBMSSebTkFn78fJQS9S/wjOt/8c=; b=lCR6H4Jm7DWoRBum3D4skL77WL61r+7QDzDi6G9xzKS4b4xA+LEilDVA4bvc6tYlBCMMPGdw3j5hSa9v1ViBIaxLPKIg/7D1auIh+k/PWG8eg/9FjMn/ka65nLI4OtS87gz2BRD7yzJxtyV2Ue3yo8qesFwCh8E00fSfv3hOCZk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668496845380889.6446705748649; Mon, 14 Nov 2022 23:20:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouqEe-0007Zp-9A; Tue, 15 Nov 2022 02:19:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ouqEa-0007Y9-0G for qemu-devel@nongnu.org; Tue, 15 Nov 2022 02:19:54 -0500 Received: from mail.weilnetz.de ([37.120.169.71] helo=mail.v2201612906741603.powersrv.de) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ouqEY-0007V3-6Y for qemu-devel@nongnu.org; Tue, 15 Nov 2022 02:19:51 -0500 Received: from qemu.weilnetz.de (qemu.weilnetz.de [188.68.58.204]) by mail.v2201612906741603.powersrv.de (Postfix) with ESMTP id 391F7DA04BF; Tue, 15 Nov 2022 08:19:46 +0100 (CET) Received: by qemu.weilnetz.de (Postfix, from userid 1000) id 996FB462074; Tue, 15 Nov 2022 08:19:45 +0100 (CET) To: qemu-devel@nongnu.org Cc: Jason Wang , Stefan Weil Subject: [PATCH for-7.2] Add G_GNUC_PRINTF to function qemu_set_info_str and fix related issues Date: Tue, 15 Nov 2022 08:19:35 +0100 Message-Id: <20221115071935.1020799-1-sw@weilnetz.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=37.120.169.71; envelope-from=stefan@weilnetz.de; helo=mail.v2201612906741603.powersrv.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Reply-to: Stefan Weil From: Stefan Weil via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1668496847485100003 Content-Type: text/plain; charset="utf-8" With the G_GNUC_PRINTF function attribute the compiler detects two potential insecure format strings: ../../../net/stream.c:248:31: warning: format string is not a string litera= l (potentially insecure) [-Wformat-security] qemu_set_info_str(&s->nc, uri); ^~~ ../../../net/stream.c:322:31: warning: format string is not a string litera= l (potentially insecure) [-Wformat-security] qemu_set_info_str(&s->nc, uri); ^~~ There are also two other warnings: ../../../net/socket.c:182:35: warning: zero-length gnu_printf format string= [-Wformat-zero-length] 182 | qemu_set_info_str(&s->nc, ""); | ^~ ../../../net/stream.c:170:35: warning: zero-length gnu_printf format string= [-Wformat-zero-length] 170 | qemu_set_info_str(&s->nc, ""); Signed-off-by: Stefan Weil Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/net/net.h | 3 ++- net/socket.c | 2 +- net/stream.c | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index 3db75ff841..dc20b31e9f 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -177,7 +177,8 @@ ssize_t qemu_send_packet_async(NetClientState *nc, cons= t uint8_t *buf, void qemu_purge_queued_packets(NetClientState *nc); void qemu_flush_queued_packets(NetClientState *nc); void qemu_flush_or_purge_queued_packets(NetClientState *nc, bool purge); -void qemu_set_info_str(NetClientState *nc, const char *fmt, ...); +void qemu_set_info_str(NetClientState *nc, + const char *fmt, ...) G_GNUC_PRINTF(2, 3); void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6]); bool qemu_has_ufo(NetClientState *nc); bool qemu_has_vnet_hdr(NetClientState *nc); diff --git a/net/socket.c b/net/socket.c index 4944bb70d5..e62137c839 100644 --- a/net/socket.c +++ b/net/socket.c @@ -179,7 +179,7 @@ static void net_socket_send(void *opaque) s->fd =3D -1; net_socket_rs_init(&s->rs, net_socket_rs_finalize, false); s->nc.link_down =3D true; - qemu_set_info_str(&s->nc, ""); + qemu_set_info_str(&s->nc, "%s", ""); =20 return; } diff --git a/net/stream.c b/net/stream.c index 53b7040cc4..37ff727e0c 100644 --- a/net/stream.c +++ b/net/stream.c @@ -167,7 +167,7 @@ static gboolean net_stream_send(QIOChannel *ioc, =20 net_socket_rs_init(&s->rs, net_stream_rs_finalize, false); s->nc.link_down =3D true; - qemu_set_info_str(&s->nc, ""); + qemu_set_info_str(&s->nc, "%s", ""); =20 qapi_event_send_netdev_stream_disconnected(s->nc.name); =20 @@ -245,7 +245,7 @@ static void net_stream_listen(QIONetListener *listener, } g_assert(addr !=3D NULL); uri =3D socket_uri(addr); - qemu_set_info_str(&s->nc, uri); + qemu_set_info_str(&s->nc, "%s", uri); g_free(uri); qapi_event_send_netdev_stream_connected(s->nc.name, addr); qapi_free_SocketAddress(addr); @@ -319,7 +319,7 @@ static void net_stream_client_connected(QIOTask *task, = gpointer opaque) addr =3D qio_channel_socket_get_remote_address(sioc, NULL); g_assert(addr !=3D NULL); uri =3D socket_uri(addr); - qemu_set_info_str(&s->nc, uri); + qemu_set_info_str(&s->nc, "%s", uri); g_free(uri); =20 ret =3D qemu_socket_try_set_nonblock(sioc->fd); --=20 2.30.2