Fix size of type 2 probe replies.
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 10 Jan 2015 22:33:55 +0000 (23:33 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Sat, 10 Jan 2015 22:33:55 +0000 (23:33 +0100)
Type 2 replies should be as small as possible. The minimum payload size
for probe packets is 14 bytes, otherwise they won't be recognized as
such.

src/net_packet.c

index 8bf399f..f219287 100644 (file)
@@ -110,7 +110,7 @@ static void udp_probe_h(node_t *n, vpn_packet_t *packet, length_t len) {
                        gettimeofday(&now, NULL);
                        uint32_t sec = htonl(now.tv_sec); memcpy(data, &sec, 4); data += 4;
                        uint32_t usec = htonl(now.tv_usec); memcpy(data, &usec, 4); data += 4;
                        gettimeofday(&now, NULL);
                        uint32_t sec = htonl(now.tv_sec); memcpy(data, &sec, 4); data += 4;
                        uint32_t usec = htonl(now.tv_usec); memcpy(data, &usec, 4); data += 4;
-                       packet->len -= 10;
+                       packet->len = 14; // Minimum size for any probe packet.
                } else {
                        /* Legacy protocol: n won't understand type 2 probe replies. */
                        DATA(packet)[0] = 1;
                } else {
                        /* Legacy protocol: n won't understand type 2 probe replies. */
                        DATA(packet)[0] = 1;