From: Guus Sliepen Date: Mon, 24 Apr 2000 08:32:57 +0000 (+0000) Subject: Added extra checks for desynchronized connection lists. Hopefully this will X-Git-Tag: release-1.0pre1~80 X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=f6802d349d946090bf9d1b6c761077c80065afa5;p=tinc Added extra checks for desynchronized connection lists. Hopefully this will fix those strange segmentation faults. --- diff --git a/src/protocol.c b/src/protocol.c index 1460fbf1..d6195377 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -323,6 +323,14 @@ int send_key_answer(conn_list_t *cl, ip_t to) strcpy(&tmp->key, my_public_key_base36); fw = lookup_conn(to); + + if(!fw) + { + syslog(LOG_ERR, "Attempting to send key answer to " IP_ADDR_S ", which does not exist?", + IP_ADDR_V(to)); + return -1; + } + if(debug_lvl > 2) syslog(LOG_DEBUG, "Sending public key to " IP_ADDR_S, IP_ADDR_V(fw->nexthop->vpn_ip)); @@ -617,6 +625,14 @@ int req_key_h(conn_list_t *cl, unsigned char *d, int len) } fw = lookup_conn(tmp->to); + + if(!fw) + { + syslog(LOG_ERR, "Attempting to forward key request to " IP_ADDR_S ", which does not exist?", + IP_ADDR_V(tmp->to)); + return -1; + } + if(debug_lvl > 3) syslog(LOG_DEBUG, "Forwarding request for public key to " IP_ADDR_S, IP_ADDR_V(fw->nexthop->vpn_ip)); @@ -673,6 +689,14 @@ int ans_key_h(conn_list_t *cl, unsigned char *d, int len) if(debug_lvl > 2) syslog(LOG_DEBUG, "Yeah! key arrived. Now do something with it."); gk = lookup_conn(tmp->from); + + if(!gk) + { + syslog(LOG_ERR, "Receiving key from " IP_ADDR_S ", which does not exist?", + IP_ADDR_V(tmp->from)); + return -1; + } + set_keys(gk, tmp); gk->status.validkey = 1; gk->status.waitingforkey = 0; @@ -681,6 +705,14 @@ int ans_key_h(conn_list_t *cl, unsigned char *d, int len) } fw = lookup_conn(tmp->to); + + if(!fw) + { + syslog(LOG_ERR, "Attempting to forward key to " IP_ADDR_S ", which does not exist?", + IP_ADDR_V(tmp->to)); + return -1; + } + if(debug_lvl > 2) syslog(LOG_DEBUG, "Forwarding public key to " IP_ADDR_S, IP_ADDR_V(fw->nexthop->vpn_ip)); @@ -703,6 +735,14 @@ int key_changed_h(conn_list_t *cl, unsigned char *d, int len) IP_ADDR_V(tmp->from)); ik = lookup_conn(tmp->from); + + if(!ik) + { + syslog(LOG_ERR, "Got changed key from " IP_ADDR_S ", which does not exist?", + IP_ADDR_V(tmp->from)); + return -1; + } + ik->status.validkey = 0; ik->status.waitingforkey = 0;