From: Vladislav Grishenko Date: Wed, 16 Sep 2020 14:17:55 +0000 (+0500) Subject: Fix fatal error at switching remotes (#629) X-Git-Tag: v2.5_rc1~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6554025a422d3d7e5465bcbfad34fa3e196b53b0;p=thirdparty%2Fopenvpn.git Fix fatal error at switching remotes (#629) If remote server has been resolved to multiple addresses, at least one connection attempt has been made and connection to the last address was skipped by management - resolved earlier link socket addrinfo objects will not be cleared neither on instance close nor in the next connection entry loop. This causes fatal error assert: >REMOTE:openvpn.net,1194,udp remote ACCEPT SUCCESS: remote command succeeded >REMOTE:openvpn.net,1194,udp remote SKIP SUCCESS: remote command succeeded >FATAL:Assertion failed at init.c:504 (c->c1.link_socket_addr.current_remote == NULL) Fix this behaviour by cleaning stale addrinfo objects. v2: better comment placement and too long length fix Signed-off-by: Vladislav Grishenko Acked-by: Lev Stipakov Message-Id: <20200916141755.1923-1-themiron@yandex-team.ru> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21019.html Signed-off-by: Gert Doering (cherry picked from commit 3ad86c2534a92af137809b6d446d570193e6d01f) --- diff --git a/src/openvpn/init.c b/src/openvpn/init.c index a785934a6..d1ad5c8f7 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -500,6 +500,17 @@ next_connection_entry(struct context *c) */ if (!c->options.persist_remote_ip) { + /* Connection entry addrinfo objects might have been + * resolved earlier but the entry itself might have been + * skipped by management on the previous loop. + * If so, clear the addrinfo objects as close_instance does + */ + if (c->c1.link_socket_addr.remote_list) + { + clear_remote_addrlist(&c->c1.link_socket_addr, + !c->options.resolve_in_advance); + } + /* close_instance should have cleared the addrinfo objects */ ASSERT(c->c1.link_socket_addr.current_remote == NULL); ASSERT(c->c1.link_socket_addr.remote_list == NULL);