From: Gert Doering Date: Sun, 31 May 2015 20:41:58 +0000 (+0200) Subject: On signal reception, return EAI_SYSTEM from openvpn_getaddrinfo(). X-Git-Tag: v2.4_alpha1~289 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f6c01ea6172ed1d8ed04e31f9f6c3f8e4696109;p=thirdparty%2Fopenvpn.git On signal reception, return EAI_SYSTEM from openvpn_getaddrinfo(). A signal (except SIGUSR1) received while waiting for getaddrinfo() is considered fatal, so openvpn_getaddrinfo() is destroying the returned information with freeaddrinfo(), but still signalled "success" (0) to the caller - so if the caller accessed *res before checking *signal_received, it would access just-free()ed memory, which on some platforms still worked and on others caused a crash. Also, ensure that *ai is also NULLed in the caller now. Trac #276 Signed-off-by: Gert Doering Acked-by: Arne Schwabe Message-Id: <1433104918-9523-1-git-send-email-gert@greenie.muc.de> URL: http://article.gmane.org/gmane.network.openvpn.devel/9764 --- diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 13ed98174..e751154ad 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -412,10 +412,13 @@ openvpn_getaddrinfo (unsigned int flags, } else { + /* turn success into failure (interrupted syscall) */ if (0 == status) { ASSERT(res); freeaddrinfo(*res); - res = NULL; + *res = NULL; + status = EAI_SYSTEM; + errno = EINTR; } goto done; }