lib/43825: p->cc can go negative in libpcap
<guy <at> alum.mit.edu>
2010-09-01 08:15:01 GMT
>Number: 43825
>Category: lib
>Synopsis: p->cc can go negative in libpcap
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Sep 01 08:15:01 +0000 2010
>Originator: Guy Harris
>Release: Top of tree
>Organization:
>Environment:
>Description:
In pcap_read_bpf(), ep is set based on the return value of read(), but read() from a BPF device doesn't
necessarily return a value that's a multiple of the alignment value for BPF_WORDALIGN(). However,
whenever we increment bp, we round up the increment value by a value rounded up by BPF_WORDALIGN(), so we
could increment bp past ep after processing the last packet in the buffer.
(The patch also fixes the case where it returns due to a pcap_breakloop() call, so it doesn't re-process packets.)
>How-To-Repeat:
Run a program that opens a capture device with a timeout of 0, in a loop, calls pcap_dispatch() with a cnt
argument of 1, and reports when it returns a value of 0. The timeout of 0 means that the read() that libpcap
does shouldn't return until there's packet data, so a timeout won't cause pcap_dispatch() to return 0. Do
a large amount of network data transfer, to fill up the BPF bucket; notice that, on occasion, the program
will report that pcap_dispatch() returns 0.
>Fix:
(Continue reading)