Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

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

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

to review the following change.


Change subject: mudp: fix handling of multiple UDP socket flags
......................................................................

mudp: fix handling of multiple UDP socket flags

The handler previously used an 'else-if' chain to process
only the first matching flag, and then overwrote
'm->multi_io->udp_flags' with a fixed value (e.g. 'ES_ERROR').
This caused remaining event bits to be ignored if multiple
flags (such as SOCKET_READ and SOCKET_WRITE) were set
simultaneously.

This patch changes the logic to test each flag independently
and clear only the bits that were actually handled.

Reported-by: Joshua Rogers <[email protected]>
Found-by: ZeroPath (https://zeropath.com)

Change-Id: I509ea79990305f39e3385136fc0d9e5fbfa68e6c
Signed-off-by: Gianmarco De Gregori <[email protected]>
---
M src/openvpn/mudp.c
1 file changed, 4 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/65/1365/1

diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c
index 71c742f..1f3594a 100644
--- a/src/openvpn/mudp.c
+++ b/src/openvpn/mudp.c
@@ -342,6 +342,7 @@
     const unsigned int mpp_flags = m->top.c2.fast_io
                                        ? (MPP_CONDITIONAL_PRE_SELECT | 
MPP_CLOSE_ON_SIGNAL)
                                        : (MPP_PRE_SELECT | 
MPP_CLOSE_ON_SIGNAL);
+    unsigned int processed_flags = 0;

 #ifdef MULTI_DEBUG_EVENT_LOOP
     char buf[16];
@@ -361,6 +362,7 @@
     if (status & SOCKET_WRITE)
     {
         multi_process_outgoing_link(m, mpp_flags);
+        processed_flags |= SOCKET_WRITE;
     }
     /* Incoming data on UDP port */
     else if (status & SOCKET_READ)
@@ -370,9 +372,10 @@
         {
             multi_process_incoming_link(m, NULL, mpp_flags, sock);
         }
+        processed_flags |= SOCKET_READ;
     }

-    m->multi_io->udp_flags = ES_ERROR;
+    m->multi_io->udp_flags &= ~processed_flags;
 }

 /*

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1365?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: I509ea79990305f39e3385136fc0d9e5fbfa68e6c
Gerrit-Change-Number: 1365
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <[email protected]>
Gerrit-Reviewer: flichtenheld <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to