Whamcloud - gitweb
mke2fs: fix fencepost error when calling strncat
authorTheodore Ts'o <tytso@mit.edu>
Thu, 10 Jul 2014 19:33:57 +0000 (15:33 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 10 Jul 2014 19:33:57 +0000 (15:33 -0400)
There were other protections which would prevent a buffer overflow
from happening, but we should fix this nevertheless.

Addresses-Coverity-Bug: #1225003
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/mk_hugefiles.c

index ea42b6c..41280f0 100644 (file)
@@ -188,7 +188,7 @@ static blk64_t get_partition_start(const char *device_name)
        cp = search_sysfs_block(st.st_rdev, path);
        if (!cp)
                return 0;
-       strncat(path, "/start", SYSFS_PATH_LEN);
+       strncat(path, "/start", SYSFS_PATH_LEN-1);
        f = fopen(path, "r");
        if (!f)
                return 0;