1
0
mirror of https://github.com/ceph/ceph synced 2025-04-01 23:02:17 +00:00

test/librbd/fsx.cc: fix BUFFER_SIZE_WARNING

CID 1296375 ( 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>
This commit is contained in:
Danny Al-Gaaf 2015-05-05 14:29:14 +02:00
parent bbeb37fc4d
commit 0a45a7a19e

View 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 {