From 910478417c43a28a8887afa816ecbe06b3c03e04 Mon Sep 17 00:00:00 2001 From: Logan oos Even <46396513+Logan007@users.noreply.github.com> Date: Mon, 18 Jan 2021 00:27:55 +0545 Subject: [PATCH] fixed a null_mac bug (#592) --- src/n2n.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/n2n.c b/src/n2n.c index 9229617..77cac44 100644 --- a/src/n2n.c +++ b/src/n2n.c @@ -328,9 +328,12 @@ struct peer_info* add_sn_to_list_by_mac_or_sock (struct peer_info **sn_list, n2n if(peer == NULL) { /* zero MAC, search by socket */ HASH_ITER(hh, *sn_list, scan, tmp) { if(memcmp(&(scan->sock), sock, sizeof(n2n_sock_t)) == 0) { - HASH_DEL(*sn_list, scan); - memcpy(scan->mac_addr, mac, sizeof(n2n_mac_t)); - HASH_ADD_PEER(*sn_list, scan); + // update mac if appropriate, needs to be deleted first because it is key to the hash list + if(!is_null_mac(mac)) { + HASH_DEL(*sn_list, scan); + memcpy(scan->mac_addr, mac, sizeof(n2n_mac_t)); + HASH_ADD_PEER(*sn_list, scan); + } peer = scan; break; }