]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-common: Fix a bug in non-Linux (PCAP) TCP packet capturing
authorMartin Schwenke <martin@meltin.net>
Fri, 17 Aug 2018 05:36:41 +0000 (15:36 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 30 Aug 2018 02:48:58 +0000 (04:48 +0200)
Captured packets include a link-layer header, which is considered in
the Linux code but not the PCAP code.  Also, the actual captured
length is in caplen, not len.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/common/system_socket.c

index 4617be48bd724a4fbc1acc38089f1df83ff3e94e..c72c61ad978d8cc8750ec272833618ed069bf37a 100644 (file)
@@ -962,7 +962,7 @@ int ctdb_sys_read_tcp_packet(int s,
 
                /* make sure its not a short packet */
                if (offsetof(struct tcphdr, th_ack) + 4 +
-                   (ip->ip_hl*4) > pkthdr.len) {
+                   (ip->ip_hl*4) + sizeof(*eth) > pkthdr.caplen) {
                        return -1;
                }
                /* TCP */