From: Steffan Karger Date: Tue, 8 Nov 2016 20:07:43 +0000 (+0100) Subject: Fix missing return value checks in multi_process_float() X-Git-Tag: v2.4_beta1~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b59fc7f42137a0474c069ab226c4d67c148e504f;p=thirdparty%2Fopenvpn.git Fix missing return value checks in multi_process_float() Fix the missing return value checks on hash_remove() and hash_add() by replacing the calls with an single hash_add() call with the replace parameters set to true so that is can't fail. Then just ASSERT() that this is indeed the case. This also replaces the other add/remove combinations with a single add-replace, because that should be slightly faster (and this is in the 'hot path'). Signed-off-by: Steffan Karger Acked-by: David Sommerseth Message-Id: <1478635663-5837-1-git-send-email-steffan@karger.me> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg12968.html Signed-off-by: David Sommerseth --- diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index b497f6ad6..8f3d34e16 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -2317,9 +2317,6 @@ 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)); - 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); @@ -2333,12 +2330,11 @@ 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, false)); - ASSERT (hash_add (m->iter, &mi->real, mi, false)); + ASSERT (hash_add (m->hash, &mi->real, mi, true)); + ASSERT (hash_add (m->iter, &mi->real, mi, true)); #ifdef MANAGEMENT_DEF_AUTH - hash_remove (m->cid_hash, &mi->context.c2.mda_context.cid); - hash_add (m->cid_hash, &mi->context.c2.mda_context.cid, mi, false); + ASSERT (hash_add (m->cid_hash, &mi->context.c2.mda_context.cid, mi, true)); #endif done: