Clear Ethernet header when reading packets from a tun device.
authorGuus Sliepen <guus@tinc-vpn.org>
Tue, 9 Oct 2012 13:52:58 +0000 (15:52 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Tue, 9 Oct 2012 13:52:58 +0000 (15:52 +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 c50005b..4b33d76 100644 (file)
@@ -238,6 +238,7 @@ static bool read_packet(vpn_packet_t *packet) {
                                        return false;
                        }
 
+                       memset(packet->data, 0, 12);
                        packet->len = inlen + 14;
                        break;
 
@@ -269,6 +270,7 @@ static bool read_packet(vpn_packet_t *packet) {
                                        return false;
                        }
 
+                       memset(packet->data, 0, 12);
                        packet->len = inlen + 10;
                        break;
                }
index 61785ad..37a057d 100644 (file)
@@ -131,6 +131,7 @@ static bool read_packet(vpn_packet_t *packet) {
                                return false;
                        }
 
+                       memset(packet->data, 0, 12);
                        packet->len = inlen + 10;
                        break;
                case DEVICE_TYPE_TAP:
index 6584b7f..cb2ece7 100644 (file)
@@ -151,6 +151,7 @@ static bool read_packet(vpn_packet_t *packet) {
                        return false;
        }
 
+       memset(packet->data, 0, 12);
        packet->len = inlen + 14;
 
        device_total_in += packet->len;