From: Guus Sliepen Date: Thu, 11 Jun 2009 16:36:08 +0000 (+0200) Subject: Don't try to send MTU probes to unreachable nodes. X-Git-Tag: release-1.0.10~52 X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=commitdiff_plain;h=36f8e4da8b1708474505f5a1fa8cf1ba848921de Don't try to send MTU probes to unreachable nodes. If there is an outstanding MTU probe event for a node which is not reachable anymore, a UDP packet would be sent to that node, which caused a key request to be sent to that node, which triggered a NULL pointer dereference. Probes and other UDP packets to unreachable nodes are now dropped. --- diff --git a/src/meta.c b/src/meta.c index a32d4137..b59f15b0 100644 --- a/src/meta.c +++ b/src/meta.c @@ -41,6 +41,11 @@ bool send_meta(connection_t *c, const char *buffer, int length) cp(); + if(!c) { + logger(LOG_ERR, _("send_meta() called with NULL pointer!")); + abort(); + } + ifdebug(META) logger(LOG_DEBUG, _("Sending %d bytes of metadata to %s (%s)"), length, c->name, c->hostname); diff --git a/src/net_packet.c b/src/net_packet.c index 40d94518..9f612751 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -70,6 +70,11 @@ void send_mtu_probe(node_t *n) n->mtuprobes++; n->mtuevent = NULL; + if(!n->status.reachable) { + ifdebug(TRAFFIC) logger(LOG_INFO, _("Trying to send MTU probe to unreachable node %s (%s)"), n->name, n->hostname); + return; + } + if(n->mtuprobes >= 10 && !n->minmtu) { ifdebug(TRAFFIC) logger(LOG_INFO, _("No response to MTU probes from %s (%s)"), n->name, n->hostname); return; @@ -328,6 +333,11 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) cp(); + if(!n->status.reachable) { + ifdebug(TRAFFIC) logger(LOG_INFO, _("Trying to send UDP packet to unreachable node %s (%s)"), n->name, n->hostname); + return; + } + /* Make sure we have a valid key */ if(!n->status.validkey) {