[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3] tools/libs/stat: fix broken build


  • To: Juergen Gross <jgross@xxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Mon, 14 Sep 2020 10:58:45 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HTv+gDqkRQwbE7GJtikvKFA9KDrc8nFmQqGexc6OOWE=; b=bGV7p1TvMtTNDH/8NnZ5W8wM33+bHVcz0gq2uEB02tLm2uY0mafEBrZ4wBV6tVvvzf74xiDmAETgSt2Rr1uf++AMleQkrDxGOwf2eUOJTWOLVNj4rHT6Bj8uxjkFLnbyVR+3B2B/29bcGyqr3LNql4CkY43YVQXQIgsshSTFfmydHUBW+KK0waBXjyw3xa+I6PdKrfu7A7FC0PWOeF/LXgmD/ryQoDp+bUhU7nu12tGJA+jy4BwX93SWn7KauNXLDOn0QcyTpWEFa0XyUAfufoheIn5xVcHUhz9sklzsInrFZqG7T8Y+DFG/M2P0GG0Tu8eNpvBJzyAPX+w6rvwxgg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ae3N+FCx5FQeBxp3KUfRNta1MB1B/nVNmEpKDjBtZxhjrjk5joBeHyC5VhJWYYaRXYOnFxW9roTam30x0TRXVBUH2JxXCwmKsm5l/bzNwGokQqeNsyTOZepxGBe02qApYxxNDNHBed4VvqlTD3NAOzHairvdMR0o3pQ1BMDZ0hnVgzV+PKcLCWJiX03RSLXcFaUA4CWhJXnm8ONvx0e/6l7dFjCBqfUXH87juWdtqlB2SHXsLejYlw3A8HsnM1zf+zR7NsgWoX2HgOYo7bJdBlfKSpUH6yiREq4sAqVPZe/BFj7Yj8s5M5gGsMafZo4j1f9CmNxY54iX5BVjiGvhEA==
  • Authentication-results-original: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=arm.com;
  • Cc: "open list:X86" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Mon, 14 Sep 2020 10:59:22 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHWiQYtlvZlYAgRJ0WaZGJ4HThwo6ln+foA
  • Thread-topic: [PATCH v3] tools/libs/stat: fix broken build


> On 12 Sep 2020, at 14:08, Juergen Gross <jgross@xxxxxxxx> wrote:
> 
> 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=stringop-truncation]
> 
> Fix that by using a buffer with 256 bytes instead.
> 
> Fixes: 6d0ec053907794 ("tools: split libxenstat into new tools/libs/stat 
> directory")
> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>

> ---
> tools/libs/stat/xenstat_linux.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/libs/stat/xenstat_linux.c b/tools/libs/stat/xenstat_linux.c
> index 793263f2b6..d2ee6fda64 100644
> --- a/tools/libs/stat/xenstat_linux.c
> +++ b/tools/libs/stat/xenstat_linux.c
> @@ -78,7 +78,7 @@ static void getBridge(char *excludeName, char *result, 
> size_t resultLen)
>                               sprintf(tmp, "/sys/class/net/%s/bridge", 
> de->d_name);
> 
>                               if (access(tmp, F_OK) == 0) {
> -                                     strncpy(result, de->d_name, resultLen - 
> 1);
> +                                     strncpy(result, de->d_name, resultLen);
>                                       result[resultLen - 1] = 0;
>                               }
>               }
> @@ -264,7 +264,7 @@ int xenstat_collect_networks(xenstat_node * node)
> {
>       /* Helper variables for parseNetDevLine() function defined above */
>       int i;
> -     char line[512] = { 0 }, iface[16] = { 0 }, devBridge[16] = { 0 }, 
> devNoBridge[17] = { 0 };
> +     char line[512] = { 0 }, iface[16] = { 0 }, devBridge[256] = { 0 }, 
> devNoBridge[257] = { 0 };
>       unsigned long long rxBytes, rxPackets, rxErrs, rxDrops, txBytes, 
> txPackets, txErrs, txDrops;
> 
>       struct priv_data *priv = get_priv_data(node->handle);
> -- 
> 2.26.2
> 
> 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.