Clear Ethernet header when reading packets from a tun device.
authorGuus Sliepen <guus@tinc-vpn.org>
Tue, 9 Oct 2012 19:02:49 +0000 (21:02 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Tue, 9 Oct 2012 19:02:49 +0000 (21:02 +0200)
This fixes a warning from valgrind about uninitialized bytes, which were being
sent to other nodes.

src/bsd/device.c
src/linux/device.c
src/solaris/device.c

index d6dd055..c91eb5e 100644 (file)
@@ -238,6 +238,7 @@ static bool read_packet(vpn_packet_t *packet) {
                                        return false;
                        }
 
+                       memset(packet->data, 0, 12);
                        packet->len = lenin + 14;
                        break;
 
@@ -269,6 +270,7 @@ static bool read_packet(vpn_packet_t *packet) {
                                        return false;
                        }
 
+                       memset(packet->data, 0, 12);
                        packet->len = lenin + 10;
                        break;
                }
index 5ae8947..f770f7f 100644 (file)
@@ -155,6 +155,7 @@ static bool read_packet(vpn_packet_t *packet) {
                                return false;
                        }
 
+                       memset(packet->data, 0, 12);
                        packet->len = lenin + 10;
                        break;
                case DEVICE_TYPE_TAP:
index 969b514..26121e2 100644 (file)
@@ -151,6 +151,7 @@ static bool read_packet(vpn_packet_t *packet) {
                        return false;
        }
 
+       memset(packet->data, 0, 12);
        packet->len = lenin + 14;
 
        device_total_in += packet->len;