]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
In x_check_status() read errno early
authorSelva Nair <selva.nair@gmail.com>
Fri, 22 Jul 2022 20:40:07 +0000 (16:40 -0400)
committerGert Doering <gert@greenie.muc.de>
Sat, 23 Jul 2022 12:05:40 +0000 (14:05 +0200)
The correct errno can get overwritten by the call to
format_extended_socket_error() which may set errno to EAGAIN
losing the original error and cause to bypass the error reporting
below. Fix by reading the errno of interest at the top of the
function.

Reported by: Gert Doering <gert@greenie.muc.de>
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220722204007.7537-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24728.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/error.c

index 49ed1dbc80af88d29e7a156a8e6c2c54493fad2b..7cd35b170ec2139a711704f4113d3cb4549a4b58 100644 (file)
@@ -658,6 +658,9 @@ x_check_status(int status,
 {
     const char *extended_msg = NULL;
 
+    bool crt_error = false;
+    int my_errno = openvpn_errno_maybe_crt(&crt_error);
+
     msg(x_cs_verbose_level, "%s %s returned %d",
         sock ? proto2ascii(sock->info.proto, sock->info.af, true) : "",
         description,
@@ -688,9 +691,6 @@ x_check_status(int status,
         }
 #endif
 
-        bool crt_error = false;
-        int my_errno = openvpn_errno_maybe_crt(&crt_error);
-
         if (!ignore_sys_error(my_errno, crt_error))
         {
             if (extended_msg)