summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomohiro Kusumi <[email protected]>2019-06-23 08:30:59 +0900
committerBrian Behlendorf <[email protected]>2019-06-22 16:30:59 -0700
commitd5bf1cf179a060e6defbbec564d557fb296d200a (patch)
treeeec3d717aae141824c1c71809e1d460cead0f53a
parenta370182fed893c65c4d5a6ec96ce70535e861c62 (diff)
Fix build break by "Implement Redacted Send/Receive"
30af21b025 broke build on Fedora. gcc can detect potential overflow on compile-time. Consider strlen of already copied string. Also change strn to strl variants per suggestion from @behlendorf and @ofaaland. -- libzfs_input_check.c: In function 'test_redact': libzfs_input_check.c:711:2: error: 'strncat' specified bound 288 equals destination size [-Werror=stringop-overflow=] strncat(bookmark, "#testbookmark", sizeof (bookmark)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Olaf Faaland <[email protected]> Signed-off-by: Tomohiro Kusumi <[email protected]> Closes #8939
-rw-r--r--tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c b/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c
index 2de1ba20c..ecdabbd14 100644
--- a/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c
+++ b/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c
@@ -706,9 +706,10 @@ test_redact(const char *snapshot1, const char *snapshot2)
nvlist_free(snapnv);
nvlist_free(required);
- strncpy(bookmark, snapshot1, sizeof (bookmark) - 1);
+ strlcpy(bookmark, snapshot1, sizeof (bookmark));
*strchr(bookmark, '@') = '\0';
- strncat(bookmark, "#testbookmark", sizeof (bookmark));
+ strlcat(bookmark, "#testbookmark", sizeof (bookmark) -
+ strlen(bookmark));
zfs_destroy(bookmark);
}