]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/librbd/fsx.cc: fix BUFFER_SIZE_WARNING
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Tue, 5 May 2015 12:29:14 +0000 (14:29 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Mon, 1 Jun 2015 04:59:26 +0000 (06:59 +0200)
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 <danny.al-gaaf@bisect.de>
src/test/librbd/fsx.cc

index 97716101d2a9519348fec2a93b020d0467590a5f..da93263d22990f728d7766cefb41a68d2e942dc4 100644 (file)
@@ -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 {