]> gitweb.fperrin.net Git - iftop.git/commit
Drop packets shorter than sizeof (struct iphdr)
authorFrédéric Perrin <fperrin@brocade.com>
Wed, 1 Apr 2015 14:24:53 +0000 (15:24 +0100)
committerFrédéric Perrin <fperrin@brocasde.com>
Thu, 23 Apr 2015 09:46:41 +0000 (09:46 +0000)
commitfda4298dc99dfd15c20a7f8b759bb79fab45f393
tree0123da2c8e775ec4155df8ce95b6cf188b5f8cea
parent93280d4777ec65285ff263a4820956244fcd0004
Drop packets shorter than sizeof (struct iphdr)

When packets that are too short to be valid IP packets happen to start
with 0x45 or 0x60, iftop will still try to read source and destination
addresses, which will usually just be random garbage.

Note the assumption about what libpcap guarantees in the comments to
handle_ip_packet():

    * It is assumed that the snaplen (currently hard-coded to 1000) is
    * big enough to always capture the IP header past the L2 encap, and
    * that pcap never truncates the packet to less than snaplen; in
    * other words, that pcaphdr->caplen = MIN(pcaphdr->len, snaplen).
iftop.c