From 8b2aca6221141cce45576115b41f52b3a5084156 Mon Sep 17 00:00:00 2001
From: Gert Doering <gert@greenie.muc.de>
Date: Sun, 31 May 2015 20:51:25 +0200
Subject: [PATCH] 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.
Signed-off-by: Gert Doering <gert@greenie.muc.de>
---
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 cf2dec3..034ccc1 100644
a
|
b
|
msg(M_INFO, "if(*signal_received)"); |
219 | 219 | } |
220 | 220 | else |
221 | 221 | { |
| 222 | /* turn success into failure (interrupted syscall) */ |
222 | 223 | if (0 == status) { |
223 | 224 | ASSERT(res); |
224 | 225 | freeaddrinfo(*res); |
225 | | res = NULL; |
| 226 | *res = NULL; |
| 227 | status = EAI_SYSTEM; |
| 228 | errno = EINTR; |
226 | 229 | } |
227 | 230 | goto done; |
228 | 231 | } |