[Openvpn-devel,v1] multi: Warn about failing read in multi_process_file_closed()

Message ID 20251216111544.27133-1-gert@greenie.muc.de
State New
Headers show
Series [Openvpn-devel,v1] multi: Warn about failing read in multi_process_file_closed() | expand

Commit Message

Gert Doering Dec. 16, 2025, 11:15 a.m. UTC
From: Frank Lichtenheld <frank@lichtenheld.com>

Handle failure explicitly instead of the implicit
handling by "while (buffer_i < r)".

Backport of 18d1b1fe008a4bbfd5a56ca7bb59f6f8cb58114a and the relevant
type fix of 5e5ead5ba019fc2a8266f77a7d840b30fd545198

Reported-by: Marc Heuse <marc@srlabs.de>
Github: openvpn-private-issues#101
Change-Id: I950863eeba67b8c006c794245a1a08752cd79fb0
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <antonio@mandelbit.com>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1444
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to release/2.6.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1444
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Antonio Quartulli <antonio@mandelbit.com>

Comments

Gert Doering Dec. 29, 2025, 4:12 p.m. UTC | #1
Backport of the relevant pieces of commit 18d1b1fe008 and 5e5ead5ba01,
and since this is a bugfix (missing/broken error handling branch), relevant
to release/2.6.  Thanks :-)

Your patch has been applied to the release/2.6 branch.

commit d8a30a5bf20eb3f57c8ccd66525b719d743df6fa
Author: Frank Lichtenheld
Date:   Tue Dec 16 12:15:39 2025 +0100

     multi: Warn about failing read in multi_process_file_closed()

     Signed-off-by: Gert Doering <gert@greenie.muc.de>
     Acked-by: Antonio Quartulli <antonio@mandelbit.com>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1444
     Message-Id: <20251216111544.27133-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35113.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
index 94e623b..69497a6 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
@@ -2830,8 +2830,13 @@ 
 multi_process_file_closed(struct multi_context *m, const unsigned int mpp_flags)
 {
     char buffer[INOTIFY_EVENT_BUFFER_SIZE];
-    size_t buffer_i = 0;
-    int r = read(m->top.c2.inotify_fd, buffer, INOTIFY_EVENT_BUFFER_SIZE);
+    ssize_t buffer_i = 0;
+    ssize_t r = read(m->top.c2.inotify_fd, buffer, INOTIFY_EVENT_BUFFER_SIZE);
+    if (r < 0)
+    {
+        msg(M_WARN | M_ERRNO, "MULTI: multi_process_file_closed error");
+        return;
+    }
 
     while (buffer_i < r)
     {