[PATCH] BUGFIX: Fix write length during IPC socket write.

14 views
Skip to first unread message

Patrick Bergeron

unread,
Jul 29, 2025, 1:17:25 PM7/29/25
to swup...@googlegroups.com
When writing data to the IPC socket, we noticed if only a partial write was done, on subsequent iteration, the call to `write` would be given the wrong number of bytes to write.
This issue has previously been reported here: https://groups.google.com/g/swupdate/c/T_ZvZJH1rqE

Signed-off-by: Patrick Bergeron <pber...@biointelligence.com>
---
 ipc/network_ipc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipc/network_ipc.c b/ipc/network_ipc.c
index e2fff782..099587d4 100644
--- a/ipc/network_ipc.c
+++ b/ipc/network_ipc.c
@@ -315,7 +315,7 @@ int ipc_send_data(int connfd, char *buf, int size)
         ssize_t len = size;
 
         while (len) {
-               ret = write(connfd, buf, (size_t)size);
+               ret = write(connfd, buf, (size_t)len);
                 if (ret < 0)
                         return ret;
                 len -= ret;
--
2.34.1

Stefano Babic

unread,
Jul 29, 2025, 1:59:30 PM7/29/25
to Patrick Bergeron, swup...@googlegroups.com


On 29.07.25 18:56, Patrick Bergeron wrote:
> When writing data to the IPC socket, we noticed if only a partial write
> was done, on subsequent iteration, the call to `write` would be given
> the wrong number of bytes to write.
> This issue has previously been reported here: https://groups.google.com/
> g/swupdate/c/T_ZvZJH1rqE <https://groups.google.com/g/swupdate/c/
> T_ZvZJH1rqE>
>
> Signed-off-by: Patrick Bergeron <pber...@biointelligence.com>
> ---
>  ipc/network_ipc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ipc/network_ipc.c b/ipc/network_ipc.c
> index e2fff782..099587d4 100644
> --- a/ipc/network_ipc.c
> +++ b/ipc/network_ipc.c
> @@ -315,7 +315,7 @@ int ipc_send_data(int connfd, char *buf, int size)
>          ssize_t len = size;
>
>          while (len) {
> -               ret = write(connfd, buf, (size_t)size);
> +               ret = write(connfd, buf, (size_t)len);
>                  if (ret < 0)
>                          return ret;
>                  len -= ret;
> --
> 2.34.1


Sure, I will apply it.

Best regards,
Stefano Babic
Reply all
Reply to author
Forward
0 new messages