From: Wang Shilong Date: Tue, 18 Jun 2019 00:38:17 +0000 (-0400) Subject: LU-12447 utils: specify correct size for lfs project buffer X-Git-Tag: 2.12.56~88 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=ffef6e3271ad1136d3ab1c2ee229b4690a6722a0 LU-12447 utils: specify correct size for lfs project buffer Enviorment: Fedora release 28 (Twenty Eight) gcc (GCC) 8.0.1 20180324 (Red Hat 8.0.1-0.20) Copyright (C) 2018 Free Software Foundation, Inc. Hit build failure: lfs_project.c: In function ‘lfs_project_item_alloc’: lfs_project.c:72:2: error: ‘strncpy’ specified bound 4096 equals destination size [-Werror=stringop-truncation] strncpy(lpi->lpi_pathname, pathname, sizeof(lpi->lpi_pathname)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test-Parameters: trivial testlist=sanity-quota Change-Id: Ia6429c47391bf503546609ec6a262fe24664bdd4 Signed-off-by: Wang Shilong Reviewed-on: https://review.whamcloud.com/35257 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Gu Zheng Reviewed-by: Oleg Drokin --- diff --git a/lustre/utils/lfs_project.c b/lustre/utils/lfs_project.c index 55caae5..f16d825 100644 --- a/lustre/utils/lfs_project.c +++ b/lustre/utils/lfs_project.c @@ -69,7 +69,7 @@ lfs_project_item_alloc(struct list_head *head, const char *pathname) return -ENOMEM; } - strncpy(lpi->lpi_pathname, pathname, sizeof(lpi->lpi_pathname)); + strncpy(lpi->lpi_pathname, pathname, sizeof(lpi->lpi_pathname) - 1); list_add_tail(&lpi->lpi_list, head); return 0;