From e76569f863125e48b2d8567bd9d1ba74e729bc24 Mon Sep 17 00:00:00 2001 From: Stephen Smalley Date: Thu, 3 May 2018 14:48:44 -0400 Subject: [PATCH] libselinux: avcstat: fix build warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the following build warning. avcstat.c: In function ‘main’: avcstat.c:113:4: error: ‘strncpy’ specified bound 4096 equals destination size [-Werror=stringop-truncation] strncpy(avcstatfile, optarg, sizeof avcstatfile); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Stephen Smalley --- libselinux/utils/avcstat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libselinux/utils/avcstat.c b/libselinux/utils/avcstat.c index 5ff582b8..884a10bf 100644 --- a/libselinux/utils/avcstat.c +++ b/libselinux/utils/avcstat.c @@ -110,7 +110,8 @@ int main(int argc, char **argv) cumulative = 1; break; case 'f': - strncpy(avcstatfile, optarg, sizeof avcstatfile); + strncpy(avcstatfile, optarg, sizeof(avcstatfile) - 1); + avcstatfile[sizeof(avcstatfile)-1] = '\0'; break; case 'h': case '-':