From: Danny Al-Gaaf Date: Tue, 5 May 2015 12:29:14 +0000 (+0200) Subject: test/librbd/fsx.cc: fix BUFFER_SIZE_WARNING X-Git-Tag: v9.0.2~68^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0a45a7a19e304a578ddb52f18e071bfa0e8adaae;p=ceph.git 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 --- 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 {