From: Roy Marples Date: Wed, 8 Mar 2017 10:48:38 +0000 (+0000) Subject: Workaround a SunOS bug with reading more than 2^31 bytes of data. X-Git-Tag: v7.0.0-beta1~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5794613641f3718499786c67428f8a586b29ecf5;p=thirdparty%2Fdhcpcd.git Workaround a SunOS bug with reading more than 2^31 bytes of data. --- diff --git a/bpf.c b/bpf.c index 360b677d..43e7dad6 100644 --- a/bpf.c +++ b/bpf.c @@ -204,6 +204,14 @@ bpf_read(struct interface *ifp, int fd, void *data, size_t len, int *flags) for (;;) { if (state->buffer_len == 0) { bytes = read(fd, state->buffer, state->buffer_size); +#if defined(__sun) + /* After 2^31 bytes, the kernel offset overflows. + * To work around this bug, lseek 0. */ + if (bytes == -1 && errno == EINVAL) { + lseek(fd, 0, SEEK_SET); + continue; + } +#endif if (bytes == -1 || bytes == 0) return bytes; state->buffer_len = (size_t)bytes; @@ -413,6 +421,7 @@ bpf_arp(struct interface *ifp, int fd) if (fd == -1) return 0; + bp = bpf; /* Check frame header. */ switch(ifp->family) {