diff mbox series

tools: swupdate-sendtohawkbit: Fix setting IPC message length

Message ID 20200929100813.31485-1-christian.storm@siemens.com
State Accepted
Headers show
Series tools: swupdate-sendtohawkbit: Fix setting IPC message length | expand

Commit Message

Storm, Christian Sept. 29, 2020, 10:08 a.m. UTC
Do not set the IPC message length based on buf as a moving pointer
nor based on size indicating the free bytes in the buffer. Instead,
calculate it on the ipc_message struct directly.

Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
 tools/swupdate-sendtohawkbit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefano Babic Oct. 1, 2020, 9:38 a.m. UTC | #1
On 29.09.20 12:08, Christian Storm wrote:
> Do not set the IPC message length based on buf as a moving pointer
> nor based on size indicating the free bytes in the buffer. Instead,
> calculate it on the ipc_message struct directly.
> 
> Signed-off-by: Christian Storm <christian.storm@siemens.com>
> ---
>  tools/swupdate-sendtohawkbit.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/swupdate-sendtohawkbit.c b/tools/swupdate-sendtohawkbit.c
> index c6e740e..59ff4ad 100644
> --- a/tools/swupdate-sendtohawkbit.c
> +++ b/tools/swupdate-sendtohawkbit.c
> @@ -92,7 +92,7 @@ int main(int argc, char *argv[]) {
>  		written = snprintf(buf, size, "}");
>  
>  	fprintf(stdout, "Sending: '%s'", msg.data.instmsg.buf);
> -	msg.data.instmsg.len = strnlen(buf, size);
> +	msg.data.instmsg.len = strnlen(msg.data.instmsg.buf, sizeof(msg.data.instmsg.buf));
>  
>  	rc = ipc_send_cmd(&msg);
>  
> 

Applied to -master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/tools/swupdate-sendtohawkbit.c b/tools/swupdate-sendtohawkbit.c
index c6e740e..59ff4ad 100644
--- a/tools/swupdate-sendtohawkbit.c
+++ b/tools/swupdate-sendtohawkbit.c
@@ -92,7 +92,7 @@  int main(int argc, char *argv[]) {
 		written = snprintf(buf, size, "}");
 
 	fprintf(stdout, "Sending: '%s'", msg.data.instmsg.buf);
-	msg.data.instmsg.len = strnlen(buf, size);
+	msg.data.instmsg.len = strnlen(msg.data.instmsg.buf, sizeof(msg.data.instmsg.buf));
 
 	rc = ipc_send_cmd(&msg);