From 66826e2285d6ef8162e5cb8e727da5ea2d9f33f2 Mon Sep 17 00:00:00 2001 From: GeLiXin Date: Wed, 19 Oct 2016 01:43:22 +0800 Subject: 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 Signed-off-by: GeLiXin Closes #5283 --- cmd/zpios/zpios_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cmd') 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)) { -- cgit v1.2.3