Package: libpcap0.8
Severity: normal
Tags: patch
Hi,
The attached quilt patch makes pcap_loop() abort if poll() indicates
an error occurred. This avoids it busy-looping when an interface goes
down during polling...
I'm not sure whether this patch should be applied as-is, because it
means pcap_loop() exits where it wouldn't before. I haven't checked
all libpcap's reverse dependencies to determine whether any would be
affected beyond arpwatch; I do know the latter would be, since it
simply exits when pcap_loop() returns. My first pass through the other
reverse dependencies seems to suggest this is a common reaction; I
don't know whether it's bad though, since exiting may be the
appropriate way of handling an interface's disappearance.
If necessary I can discuss this upstream...
Regards,
Stephen
-- System Information:
Debian Release: squeeze/sid
APT prefers testing
APT policy: (500, 'testing'), (500, 'stable'), (200, 'unstable'), (1,
'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.30-2-686 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages libpcap0.8 depends on:
ii libc6 2.9-25 GNU C Library: Shared libraries
libpcap0.8 recommends no packages.
libpcap0.8 suggests no packages.
-- no debconf information
poll() can also indicate errors on the items being polled by setting
the POLLERR bit in the returned events, without poll() itself
returning an error code. This patch makes pcap_loop() abort when this
happens.
--- libpcap-1.0.0.orig/pcap-linux.c
+++ libpcap-1.0.0/pcap-linux.c
@@ -2193,7 +2193,7 @@
/* poll() requires a negative timeout to wait forever */
ret = poll(&pollinfo, 1, (handle->md.timeout > 0)?
handle->md.timeout: -1);
- if ((ret < 0) && (errno != EINTR)) {
+ if (((ret < 0) || (pollinfo.revents & POLLERR)) &&
(errno != EINTR)) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
"can't poll on packet socket fd %d:
%d-%s",
handle->fd, errno,
pcap_strerror(errno));