Skip to content

Commit

Permalink
test/librbd/fsx.cc: fix BUFFER_SIZE_WARNING
Browse files Browse the repository at this point in the history
CID 1296375 (yehudasa#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>
  • Loading branch information
dalgaaf committed Jun 1, 2015
1 parent bbeb37f commit 0a45a7a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/test/librbd/fsx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0a45a7a

Please sign in to comment.