diff mbox

lib: fwts_pipeio: fix incorrect size of command being passed

Message ID 20170413094240.27068-1-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King April 13, 2017, 9:42 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Using sizeof(command) is clearly incorrect, we should be passing
the length of the command instead of the size of the pointer.

Detected with static analysis.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_pipeio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alex Hung April 17, 2017, 5:14 p.m. UTC | #1
On 2017-04-13 02:42 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Using sizeof(command) is clearly incorrect, we should be passing
> the length of the command instead of the size of the pointer.
>
> Detected with static analysis.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_pipeio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_pipeio.c b/src/lib/src/fwts_pipeio.c
> index a2c941f4..fd719640 100644
> --- a/src/lib/src/fwts_pipeio.c
> +++ b/src/lib/src/fwts_pipeio.c
> @@ -342,7 +342,7 @@ int fwts_exec2(const char *command, char **output)
>  	}
>
>  	if (fwts_pipe_readwrite(in_fd,
> -		command, sizeof(command),
> +		command, strlen(command),
>  		out_fd, output, &out_len)) {
>  		return -1;
>  	}
>

Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu April 21, 2017, 2:23 a.m. UTC | #2
On 04/13/2017 05:42 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Using sizeof(command) is clearly incorrect, we should be passing
> the length of the command instead of the size of the pointer.
>
> Detected with static analysis.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_pipeio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_pipeio.c b/src/lib/src/fwts_pipeio.c
> index a2c941f4..fd719640 100644
> --- a/src/lib/src/fwts_pipeio.c
> +++ b/src/lib/src/fwts_pipeio.c
> @@ -342,7 +342,7 @@ int fwts_exec2(const char *command, char **output)
>  	}
>
>  	if (fwts_pipe_readwrite(in_fd,
> -		command, sizeof(command),
> +		command, strlen(command),
>  		out_fd, output, &out_len)) {
>  		return -1;
>  	}
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox

Patch

diff --git a/src/lib/src/fwts_pipeio.c b/src/lib/src/fwts_pipeio.c
index a2c941f4..fd719640 100644
--- a/src/lib/src/fwts_pipeio.c
+++ b/src/lib/src/fwts_pipeio.c
@@ -342,7 +342,7 @@  int fwts_exec2(const char *command, char **output)
 	}
 
 	if (fwts_pipe_readwrite(in_fd,
-		command, sizeof(command),
+		command, strlen(command),
 		out_fd, output, &out_len)) {
 		return -1;
 	}