]> 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:53:07 +0000 (16:53 +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
(cherry picked from commit 5f6c01ea6172ed1d8ed04e31f9f6c3f8e4696109)

src/openvpn/socket.c

index af13e3620f3b8847866975ebbd6374a45ce093ee..bff22a939709ea5211f3c854c3cbd1e479e19560 100644 (file)
@@ -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;
                     }