From nobody Thu Apr 25 18:06:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1565704422; cv=none; d=zoho.com; s=zohoarc; b=cpIpyJxcb3+vjxKblqDSLaEn5HP4Q8r1GRAJ6tVH/0Fpk2Omc/QcZ7jnNbyJGcywNQvPzZi7DI/eG6IS16WTjVhk9Tfmjx+wtk6qTOQ07yb61XWVESgx/JSI0aR89ZFlwQMV+tCFOBFj7HWPh9XZjg91PSu+PxX5dyM6IvlHk+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565704422; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=fj7Y7lQxkFYENHLpAohN1hKflIZRLuwG0cJIZ8+b4pE=; b=V3P4S09VXQopmihIY6bI/dqmFIEmNtVn2xjeDe3IRrOg0/mEmALcsCMfKjqw2LjxDVtoTEQez/FtEeEqBFxcmbPcznjFKT3ZAo0Re+RoriWOGln0tw/FuCg8rm8OVD+BiqwZ+bVzPzrKubZvLlRaCSYy3FT29ENfmD5N+gGSX9w= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1565704422174393.2520751199178; Tue, 13 Aug 2019 06:53:42 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hxXDm-0006SG-CB; Tue, 13 Aug 2019 13:52:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hxXDk-0006S8-G3 for xen-devel@lists.xenproject.org; Tue, 13 Aug 2019 13:52:16 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8e7c79c4-bdd1-11e9-ace5-33e37f24dc84; Tue, 13 Aug 2019 13:52:15 +0000 (UTC) X-Inumbo-ID: 8e7c79c4-bdd1-11e9-ace5-33e37f24dc84 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1565704335; h=from:to:cc:subject:date:message-id:mime-version; bh=i7Olcy1mMFqeL4hThALbIgKSUsvURztvVTRhgDHjJuI=; b=R5yhL32AGTV5OL4uUyRfk1ADPbf4B+J6iMXjX8o0IQBxoreJNAKQP2QY RjFGnVpbuAaq9iLF8cga6/wPeOQUBzlZ7HVsmNsyKHayxO+25dYlECb8Y ulTWi4oA6PQ9LBi9NAkqWTEp+FvBHELSwd0skWYK08GeKJyuslhZqCkWV U=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: azq86Yq4fQtESadWrLJiDNfIaFmipZ86eSLsTXkH7AUkeho2BGAhiHmZrFWbm2l2rTEjBLKnx0 5TEdDqkoLwHKCYv8QGeFv2UWzSVnwLVHu0nUlgay5wT4EATItzPi5BxkhUkUOl+ohcDLTxJFYX 8/GYwYqlzdqwAH8DVD7ZnsR5qPmVcu8hW8EIsckvQiZYpj+9HXj61SliIwbXHe/EGXiRthBAw/ cnRo1oxMRdbB4Tl2waQbO51RHMw0wiGKHKgjKJ9LSa95q+qBa6biNayMksaqj38rbb47BAuW1Z iS0= X-SBRS: 2.7 X-MesageID: 4408663 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,381,1559534400"; d="scan'208";a="4408663" From: Andrew Cooper To: Xen-devel Date: Tue, 13 Aug 2019 14:52:11 +0100 Message-ID: <20190813135211.13668-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] tools/xenstat: Fix -Wformat-truncation= issue X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Ian Jackson Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Building with GCC 8.3 on Buster identifies: src/xenstat_linux.c: In function 'xenstat_collect_networks': src/xenstat_linux.c:307:32: warning: 'snprintf' output may be truncated b= efore the last format character [-Wformat-truncation=3D] snprintf(devNoBridge, 16, "p%s", devBridge); ^ src/xenstat_linux.c:307:2: note: 'snprintf' output between 2 and 17 bytes= into a destination of size 16 snprintf(devNoBridge, 16, "p%s", devBridge); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ devNoBridge[] needs one charater more than devBridge[], so allocate one byte more. Replace a raw 16 in the snprintf() call with a sizeof() expression instead. Finally, libxenstat, unlike most of the rest of the Xen, doesn't use -Werror which is why this issue went unnoticed in CI. Fix this. Signed-off-by: Andrew Cooper Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu --- tools/xenstat/libxenstat/Makefile | 2 +- tools/xenstat/libxenstat/src/xenstat_linux.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/xenstat/libxenstat/Makefile b/tools/xenstat/libxenstat/M= akefile index 58f9d63de5..ea115ae0e6 100644 --- a/tools/xenstat/libxenstat/Makefile +++ b/tools/xenstat/libxenstat/Makefile @@ -31,7 +31,7 @@ OBJECTS-$(CONFIG_NetBSD) +=3D src/xenstat_netbsd.o OBJECTS-$(CONFIG_FreeBSD) +=3D src/xenstat_freebsd.o SONAME_FLAGS=3D-Wl,$(SONAME_LDFLAG) -Wl,libxenstat.so.$(MAJOR) =20 -CFLAGS+=3D-fPIC +CFLAGS+=3D-fPIC -Werror CFLAGS+=3D-Isrc $(CFLAGS_libxenctrl) $(CFLAGS_libxenstore) $(CFLAGS_xeninc= lude) -include $(XEN_ROOT)/tools/config.h =20 LDLIBS-y =3D $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) -lyajl diff --git a/tools/xenstat/libxenstat/src/xenstat_linux.c b/tools/xenstat/l= ibxenstat/src/xenstat_linux.c index 9421ca43c8..7530349eee 100644 --- a/tools/xenstat/libxenstat/src/xenstat_linux.c +++ b/tools/xenstat/libxenstat/src/xenstat_linux.c @@ -264,7 +264,7 @@ int xenstat_collect_networks(xenstat_node * node) { /* Helper variables for parseNetDevLine() function defined above */ int i; - char line[512] =3D { 0 }, iface[16] =3D { 0 }, devBridge[16] =3D { 0 }, d= evNoBridge[16] =3D { 0 }; + char line[512] =3D { 0 }, iface[16] =3D { 0 }, devBridge[16] =3D { 0 }, d= evNoBridge[17] =3D { 0 }; unsigned long long rxBytes, rxPackets, rxErrs, rxDrops, txBytes, txPacket= s, txErrs, txDrops; =20 struct priv_data *priv =3D get_priv_data(node->handle); @@ -304,7 +304,7 @@ int xenstat_collect_networks(xenstat_node * node) =20 /* We get the bridge devices for use with bonding interface to get bondin= g interface stats */ getBridge("vir", devBridge, sizeof(devBridge)); - snprintf(devNoBridge, 16, "p%s", devBridge); + snprintf(devNoBridge, sizeof(devNoBridge), "p%s", devBridge); =20 while (fgets(line, 512, priv->procnetdev)) { xenstat_domain *domain; --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel