]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
multi_process_float: revert part of c14c4a9e
authorSteffan Karger <steffan@karger.me>
Sat, 19 Nov 2016 17:12:46 +0000 (18:12 +0100)
committerGert Doering <gert@greenie.muc.de>
Sat, 19 Nov 2016 18:58:43 +0000 (19:58 +0100)
Commit c14c4a9e merged the hash_remove() and hash_add() calls in
multi_process_float(), but didn't notice that the hash key (mi->real) was
updated between these calls.  So we now try to remove the *new* address
instead of the *old* address from the hash table.  This leaks memory and
might break stuff when a different client floats to the old address/port of
this client.  Restore that.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1479575566-21198-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13128.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/multi.c

index 8f3d34e160ba7f2ad886de61b94a9b49cfbeec8d..4fc8b026480dca30d9e7e2be2c3be2c878ade83c 100644 (file)
@@ -2317,6 +2317,10 @@ void multi_process_float (struct multi_context* m, struct multi_instance* mi)
        mroute_addr_print (&mi->real, &gc),
        print_link_socket_actual (&m->top.c2.from, &gc));
 
+    /* remove old address from hash table before changing address */
+    ASSERT (hash_remove (m->hash, &mi->real));
+    ASSERT (hash_remove (m->iter, &mi->real));
+
     /* change external network address of the remote peer */
     mi->real = real;
     generate_prefix (mi);
@@ -2330,8 +2334,8 @@ void multi_process_float (struct multi_context* m, struct multi_instance* mi)
 
     tls_update_remote_addr (mi->context.c2.tls_multi, &mi->context.c2.from);
 
-    ASSERT (hash_add (m->hash, &mi->real, mi, true));
-    ASSERT (hash_add (m->iter, &mi->real, mi, true));
+    ASSERT (hash_add (m->hash, &mi->real, mi, false));
+    ASSERT (hash_add (m->iter, &mi->real, mi, false));
 
 #ifdef MANAGEMENT_DEF_AUTH
     ASSERT (hash_add (m->cid_hash, &mi->context.c2.mda_context.cid, mi, true));