Message ID | 20200929100813.31485-1-christian.storm@siemens.com |
---|---|
State | Accepted |
Headers | show |
Series | tools: swupdate-sendtohawkbit: Fix setting IPC message length | expand |
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 --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);
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(-)