From: Selva Nair Date: Fri, 22 Jul 2022 20:40:07 +0000 (-0400) Subject: In x_check_status() read errno early X-Git-Tag: v2.6_beta1~154 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95afd63ac74197980ecff2b3ecb2116d62035f7f;p=thirdparty%2Fopenvpn.git In x_check_status() read errno early 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 Signed-off-by: Selva Nair Acked-by: Gert Doering 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 --- diff --git a/src/openvpn/error.c b/src/openvpn/error.c index 49ed1dbc8..7cd35b170 100644 --- a/src/openvpn/error.c +++ b/src/openvpn/error.c @@ -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)