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 <[email protected]>
---
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 '-':
--
2.14.3