Don't echo broadcast packets back when Broadcast = direct.
[tinc] / src / net_packet.c
index c209248..81d0572 100644 (file)
@@ -1,7 +1,7 @@
 /*
     net_packet.c -- Handles in- and outgoing VPN packets
     Copyright (C) 1998-2005 Ivo Timmermans,
-                  2000-2012 Guus Sliepen <guus@tinc-vpn.org>
+                  2000-2013 Guus Sliepen <guus@tinc-vpn.org>
                   2010      Timothy Redaelli <timothy@redaelli.eu>
                   2010      Brandon Black <blblack@gmail.com>
 
@@ -394,6 +394,9 @@ static void receive_udppacket(node_t *n, vpn_packet_t *inpkt) {
 void receive_tcppacket(connection_t *c, const char *buffer, int len) {
        vpn_packet_t outpkt;
 
+       if(len > sizeof outpkt.data)
+               return;
+
        outpkt.len = len;
        if(c->options & OPTION_TCPONLY)
                outpkt.priority = 0;
@@ -647,7 +650,7 @@ void broadcast_packet(const node_t *from, vpn_packet_t *packet) {
                        for(node = node_udp_tree->head; node; node = node->next) {
                                n = node->data;
 
-                               if(n->status.reachable && ((n->via == myself && n->nexthop == n) || n->via == n))
+                               if(n->status.reachable && n != myself && ((n->via == myself && n->nexthop == n) || n->via == n))
                                        send_packet(n, packet);
                        }
                        break;