diff mbox series

BUGFIX: Fix write length during IPC socket write.

Message ID YT2PR01MB598346C2004E4E51557B3499B025A@YT2PR01MB5983.CANPRD01.PROD.OUTLOOK.COM
State Accepted
Headers show
Series BUGFIX: Fix write length during IPC socket write. | expand

Commit Message

Patrick Bergeron July 29, 2025, 4:56 p.m. UTC
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 <pbergeron@biointelligence.com>
---
 ipc/network_ipc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
2.34.1

Comments

Stefano Babic July 29, 2025, 5:59 p.m. UTC | #1
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 <pbergeron@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
diff mbox series

Patch

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;