From ffef6e3271ad1136d3ab1c2ee229b4690a6722a0 Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Mon, 17 Jun 2019 20:38:17 -0400 Subject: [PATCH] LU-12447 utils: specify correct size for lfs project buffer MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- lustre/utils/lfs_project.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 1.8.3.1