From 38c9f980d4f7cb7061f9db3ed8645ab3404e533d Mon Sep 17 00:00:00 2001 From: Gert Doering Date: Sun, 31 May 2015 22:41:58 +0200 Subject: 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 (cherry picked from commit 5f6c01ea6172ed1d8ed04e31f9f6c3f8e4696109) --- src/openvpn/socket.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index af13e36..bff22a9 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -215,10 +215,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; } -- cgit