diff mbox series

[2/2] network_notifier: fix partial initialization of ipcmsg

Message ID 20211122100706.2775865-1-dominique.martinet@atmark-techno.com
State Superseded
Headers show
Series None | expand

Commit Message

Dominique MARTINET Nov. 22, 2021, 10:07 a.m. UTC
ipcmsg.data.msg is a small part of the union (128 bytes of 2048+),
so the send_notify_msg below sends uninitalized bytes over the socket.

These are normally not accessed so it is not an important fix, but
might as well fix valgrind warnings

Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
---
This is 100% unrelated, I should probably have sent separately but ran
out of time today, sorry -- feel free to ignore this one if you're not
interested.

 core/network_thread.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

James Hilliard Nov. 22, 2021, 10:09 a.m. UTC | #1
On Mon, Nov 22, 2021 at 3:07 AM Dominique Martinet
<dominique.martinet@atmark-techno.com> wrote:
>
> ipcmsg.data.msg is a small part of the union (128 bytes of 2048+),
> so the send_notify_msg below sends uninitalized bytes over the socket.
>
> These are normally not accessed so it is not an important fix, but
> might as well fix valgrind warnings
>
> Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
> ---
> This is 100% unrelated, I should probably have sent separately but ran
> out of time today, sorry -- feel free to ignore this one if you're not
> interested.
>
>  core/network_thread.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/core/network_thread.c b/core/network_thread.c
> index c16775d37763..4dd3ec27ae8f 100644
> --- a/core/network_thread.c
> +++ b/core/network_thread.c
> @@ -207,7 +207,7 @@ static void network_notifier(RECOVERY_STATUS status, int error, int level, const
>
>         ipcmsg.magic = IPC_MAGIC;
>         ipcmsg.type = NOTIFY_STREAM;
> -       memset(ipcmsg.data.msg, 0, sizeof(ipcmsg.data.msg));
> +       memset(&ipcmsg.data, 0, sizeof(ipcmsg.data));

This looks like it's a duplicate of:
https://github.com/sbabic/swupdate/commit/38372f3e0eb9186cb39ce0f4072c078addc18643

>
>         strncpy(ipcmsg.data.notify.msg, newmsg->msg,
>                         sizeof(ipcmsg.data.notify.msg) - 1);
> --
> 2.30.2
>
> --
> You received this message because you are subscribed to the Google Groups "swupdate" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to swupdate+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/swupdate/20211122100706.2775865-1-dominique.martinet%40atmark-techno.com.
Dominique MARTINET Nov. 22, 2021, 10:11 a.m. UTC | #2
James Hilliard wrote on Mon, Nov 22, 2021 at 03:09:26AM -0700:
> >         ipcmsg.magic = IPC_MAGIC;
> >         ipcmsg.type = NOTIFY_STREAM;
> > -       memset(ipcmsg.data.msg, 0, sizeof(ipcmsg.data.msg));
> > +       memset(&ipcmsg.data, 0, sizeof(ipcmsg.data));
> 
> This looks like it's a duplicate of:
> https://github.com/sbabic/swupdate/commit/38372f3e0eb9186cb39ce0f4072c078addc18643

Right, nothing goes well when one hurries...

Thanks for noticing! :)
diff mbox series

Patch

diff --git a/core/network_thread.c b/core/network_thread.c
index c16775d37763..4dd3ec27ae8f 100644
--- a/core/network_thread.c
+++ b/core/network_thread.c
@@ -207,7 +207,7 @@  static void network_notifier(RECOVERY_STATUS status, int error, int level, const
 
 	ipcmsg.magic = IPC_MAGIC;
 	ipcmsg.type = NOTIFY_STREAM;
-	memset(ipcmsg.data.msg, 0, sizeof(ipcmsg.data.msg));
+	memset(&ipcmsg.data, 0, sizeof(ipcmsg.data));
 
 	strncpy(ipcmsg.data.notify.msg, newmsg->msg,
 			sizeof(ipcmsg.data.notify.msg) - 1);