diff options
author | GeLiXin <[email protected]> | 2016-10-19 01:43:22 +0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-10-18 10:43:22 -0700 |
commit | 66826e2285d6ef8162e5cb8e727da5ea2d9f33f2 (patch) | |
tree | 1769d3aa90720089bf3a31c130170da5e9182115 | |
parent | 1b81ab46d060257288ee9739f7e9c5199deb901b (diff) |
Fix coverity defects: CID 147643, 152204, 49339
CID 147643: Type: String not null terminated
- make sure that the string is null terminated before strlen
and fprintf.
CID 152204: Type: Copy into fixed size buffer
- since strlcpy isn't availabe here, use strncpy and terminate
the string manually.
CID 49339: Type: Buffer not null terminated
- since strlcpy isn't availabe here, terminate the string
manually before fprintf.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: GeLiXin <[email protected]>
Closes #5283
-rw-r--r-- | cmd/zpios/zpios_main.c | 3 | ||||
-rw-r--r-- | tests/zfs-tests/tests/functional/ctime/ctime_001_pos.c | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/cmd/zpios/zpios_main.c b/cmd/zpios/zpios_main.c index a413453e4..9110488fb 100644 --- a/cmd/zpios/zpios_main.c +++ b/cmd/zpios/zpios_main.c @@ -550,7 +550,8 @@ run_one(cmd_args_t *args, uint32_t id, uint32_t T, uint32_t N, print_stats(args, cmd); if (args->verbose) { - rc2 = read(zpiosctl_fd, zpios_buffer, zpios_buffer_size - 1); + rc2 = read(zpiosctl_fd, zpios_buffer, zpios_buffer_size); + zpios_buffer[zpios_buffer_size - 1] = '\0'; if (rc2 < 0) { fprintf(stdout, "Error reading results: %d\n", rc2); } else if ((rc2 > 0) && (strlen(zpios_buffer) > 0)) { diff --git a/tests/zfs-tests/tests/functional/ctime/ctime_001_pos.c b/tests/zfs-tests/tests/functional/ctime/ctime_001_pos.c index 4052b5e0b..73528d21d 100644 --- a/tests/zfs-tests/tests/functional/ctime/ctime_001_pos.c +++ b/tests/zfs-tests/tests/functional/ctime/ctime_001_pos.c @@ -154,7 +154,8 @@ do_link(const char *pfile) return (-1); } - strcpy(pfile_copy, pfile); + strncpy(pfile_copy, pfile, sizeof (pfile_copy)); + pfile_copy[sizeof (pfile_copy) - 1] = '\0'; /* * Figure out source file directory name, and create * the link file in the same directory. |