summaryrefslogtreecommitdiff
path: root/os/windows/posix.c
diff options
context:
space:
mode:
authorTomohiro Kusumi <tkusumi@tuxera.com>2017-09-18 20:53:50 +0300
committerJens Axboe <axboe@kernel.dk>2017-09-18 12:04:38 -0600
commit13a85be93769986e03662e8dae6f8bfdf2971aa9 (patch)
tree89409b8c9fe96abb9fd69b15575a95d41b0bf693 /os/windows/posix.c
parentba8b89a1549c5ce7d7544813c9137798de454fac (diff)
downloadfio-13a85be93769986e03662e8dae6f8bfdf2971aa9.tar.gz
fio-13a85be93769986e03662e8dae6f8bfdf2971aa9.tar.bz2
fix strncpy(3) copy length
0 terminate the last byte, and copy at most size-1. (or 0 terminate the last byte after copying upto size bytes) Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'os/windows/posix.c')
-rwxr-xr-xos/windows/posix.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/os/windows/posix.c b/os/windows/posix.c
index 488d0ed2..00f03355 100755
--- a/os/windows/posix.c
+++ b/os/windows/posix.c
@@ -584,7 +584,8 @@ char *basename(char *path)
while (path[i] != '\\' && path[i] != '/' && i >= 0)
i--;
- strncpy(name, path + i + 1, MAX_PATH);
+ name[MAX_PATH - 1] = '\0';
+ strncpy(name, path + i + 1, MAX_PATH - 1);
return name;
}