userland - dhclient - Fix possible infinite loop
authorSamuel J. Greear <sjg@thesjg.com>
Thu, 9 Sep 2010 01:12:31 +0000 (01:12 +0000)
committerSamuel J. Greear <sjg@thesjg.com>
Thu, 9 Sep 2010 01:12:31 +0000 (01:12 +0000)
commitdb2a08265dc67538d417f14ccdc9fdef6fb0d60b
treedb1745b2725a015ed4255eb0b2a64c2bf089832a
parentcffbd125c09076b18595db53d8de479b18beccb7
userland - dhclient - Fix possible infinite loop

FreeBSD commit message:

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>

Reported-by: Many
Obtained-from: FreeBSD
sbin/dhclient/bpf.c