From nobody Thu Apr 18 06:41:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1599830148; cv=none; d=zohomail.com; s=zohoarc; b=bY5tmTW5w6QfWIOPZ3go5K6qrwbTxoMjfjxnsNlSFx+eWXEhGY1a62nK5B2XbFud9LMTC1HmiAw/GB5NTeX/VGy+h/n3M7vTQY27Q1x+UalnqGO0tyiDRTyhkZkgnGzSU76nQTKpU8izAzQXWDXL6YgVDL+7lY+lgbuwuGTn6yw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599830148; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=dhG4K662x34LhtDJr8U5cnBCd2YS7hMMrdOUuGl4iIE=; b=beuRL66rB8JEUqZyb+mNm/z9LZJkuxZi7DsHzUfTOgYEmUaXvVlmVeKhzqhszlyDEIYYp+TyLChAe6e+yalvKu0ydldG/BcfNwftmSqFVVrMkXdLeYGPPK5dVQKHgMY8fJDO+14s8zU3OTpMT4CQwL+vFARjrTG8J8MXFmouPK8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) 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 1599830148610566.6841156421156; Fri, 11 Sep 2020 06:15:48 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kGitq-0002Bt-DT; Fri, 11 Sep 2020 13:15:34 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kGitp-0002Bn-J9 for xen-devel@lists.xenproject.org; Fri, 11 Sep 2020 13:15:33 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 0285a55a-a116-4504-8285-46939919917e; Fri, 11 Sep 2020 13:15:31 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 20BCDAE02; Fri, 11 Sep 2020 13:15:46 +0000 (UTC) X-Inumbo-ID: 0285a55a-a116-4504-8285-46939919917e X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Ian Jackson , Wei Liu Subject: [PATCH] tools/libs/stat: fix broken build Date: Fri, 11 Sep 2020 15:15:28 +0200 Message-Id: <20200911131528.19734-1-jgross@suse.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Content-Type: text/plain; charset="utf-8" Making getBridge() static triggered a build error with some gcc versions: error: 'strncpy' output may be truncated copying 15 bytes from a string of length 255 [-Werror=3Dstringop-truncation] Fix that by printing a sane error message and bailing out in case the name = of a bridge is too long. Fixes: 6d0ec053907794 ("tools: split libxenstat into new tools/libs/stat di= rectory") Signed-off-by: Juergen Gross --- tools/libs/stat/xenstat_linux.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/libs/stat/xenstat_linux.c b/tools/libs/stat/xenstat_linu= x.c index 793263f2b6..ce38b3433f 100644 --- a/tools/libs/stat/xenstat_linux.c +++ b/tools/libs/stat/xenstat_linux.c @@ -75,6 +75,12 @@ static void getBridge(char *excludeName, char *result, s= ize_t resultLen) while ((de =3D readdir(d)) !=3D NULL) { if ((strlen(de->d_name) > 0) && (de->d_name[0] !=3D '.') && (strstr(de->d_name, excludeName) =3D=3D NULL)) { + if (strlen(de->d_name) > resultLen - 1) { + fprintf(stderr, + "bridge name %s too long\n", + de->d_name); + break; + } sprintf(tmp, "/sys/class/net/%s/bridge", de->d_name); =20 if (access(tmp, F_OK) =3D=3D 0) { --=20 2.26.2