]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
On signal reception, return EAI_SYSTEM from openvpn_getaddrinfo().
authorGert Doering <gert@greenie.muc.de>
Sun, 31 May 2015 20:41:58 +0000 (22:41 +0200)
committerGert Doering <gert@greenie.muc.de>
Mon, 1 Jun 2015 14:52:19 +0000 (16:52 +0200)
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 <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1433104918-9523-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9764

src/openvpn/socket.c

index 13ed98174242bfd5b04dc1b91d5b4c7746ebe801..e751154adcf8eda1ddf3d603f8c87fe802ce0c9e 100644 (file)
@@ -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;
                     }