From 0a45a7a19e304a578ddb52f18e071bfa0e8adaae Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Tue, 5 May 2015 14:29:14 +0200 Subject: [PATCH] test/librbd/fsx.cc: fix BUFFER_SIZE_WARNING CID 1296375 (#1 of 1): Buffer not null terminated (BUFFER_SIZE_WARNING) buffer_size_warning: Calling strncpy with a maximum size argument of 1024 bytes on destination array logfile of size 1024 bytes might leave the destination string unterminated. Signed-off-by: Danny Al-Gaaf --- src/test/librbd/fsx.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/librbd/fsx.cc b/src/test/librbd/fsx.cc index 97716101d2a95..da93263d22990 100644 --- a/src/test/librbd/fsx.cc +++ b/src/test/librbd/fsx.cc @@ -2126,7 +2126,8 @@ main(int argc, char **argv) prt("file name to long\n"); exit(1); } - strncpy(logfile, dirpath, sizeof(logfile)); + strncpy(logfile, dirpath, sizeof(logfile)-1); + logfile[sizeof(logfile)-1] = '\0'; if (strlen(logfile) < sizeof(logfile)-2) { strcat(logfile, "/"); } else {