It is possible for bpf to return a length such that:

length != BPF_WORDALIGN(length)

This meeans that it is possible for this to be true:

	interface->rbuf_offset > interface->rbuf_len

Handle this case in the test for running out of packets.  While
OpenBSD's solution of setting interface->rbuf_len to
BPF_WORDALIGN(length) is safe due to the size of the buffer, I think
this solution results in less hidden assumptions.

This should fix the problem of dhclient running away and consuming 100%
CPU.

PR:		bin/102226
Submitted by:	Joost Bekkers <joost at jodocus.org>
MFC after:	3 days
This commit is contained in:
Brooks Davis 2006-09-26 01:02:02 +00:00
parent 88b85279a9
commit ebe609b4a2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=162641

View file

@ -282,7 +282,7 @@ receive_packet(struct interface_info *interface, unsigned char *buf,
*/
do {
/* If the buffer is empty, fill it. */
if (interface->rbuf_offset == interface->rbuf_len) {
if (interface->rbuf_offset >= interface->rbuf_len) {
length = read(interface->rfdesc, interface->rbuf,
interface->rbuf_max);
if (length <= 0)