Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1639?usp=email

to review the following change.


Change subject: Avoid recursive call of man_read
......................................................................

Avoid recursive call of man_read

Recursion to `man_read()` happens on Windows when `man_process_command`
tries to log the received command because `management_io`
first checks FD_READ and calls `man_read()` again if there is data is
pending in the receive buffer. This is buggy as `man_read()` is not
designed to be re-entrant.

Fix this by disallowing recursion -- just return 0 so that managament_io
will complete without recursion. Although this will also clear
FD_READ from the event mask via
    `net_event_win32_clear_selected_events(&man->connection.ne32, FD_READ)`
(manage.c:3312), read will get serviced next time when the main event loop
calls `management_io` thorugh `process_io`.  Note that `management_io`
always calls `reset_net_event_win32()` (manage.c: 3298) which will pickup
if any data to read is pending (win32.c: 357) as FD_READ is level triggered.

Giithub: Fixes OpenVPN/openvpn#1023

Change-Id: I9433baee1f5a66d43d4e43e03128ae6a790a7937
Signed-off-by: Selva Nair <[email protected]>
---
M src/openvpn/manage.c
1 file changed, 8 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/39/1639/1

diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c
index 2a3023c..4d46e61 100644
--- a/src/openvpn/manage.c
+++ b/src/openvpn/manage.c
@@ -2425,6 +2425,13 @@
      */
     unsigned char buf[256];
     ssize_t len = 0;
+    static int recursive_level = 0;
+
+    if (recursive_level > 0)
+    {
+        return 0; /* not ready to read now */
+    }
+    recursive_level++;

 #ifdef TARGET_ANDROID
     int fd;
@@ -2508,6 +2515,7 @@
             man_reset_client_socket(man, false);
         }
     }
+    recursive_level--;
     return len;
 }


--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1639?usp=email
To unsubscribe, or for help writing mail filters, visit 
http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9433baee1f5a66d43d4e43e03128ae6a790a7937
Gerrit-Change-Number: 1639
Gerrit-PatchSet: 1
Gerrit-Owner: selvanair <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to