summaryrefslogtreecommitdiffstats
path: root/contrib/ipfilter/lib/ipft_pc.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ipfilter/lib/ipft_pc.c')
-rw-r--r--contrib/ipfilter/lib/ipft_pc.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/contrib/ipfilter/lib/ipft_pc.c b/contrib/ipfilter/lib/ipft_pc.c
index 9b7da65..e3e2bd3 100644
--- a/contrib/ipfilter/lib/ipft_pc.c
+++ b/contrib/ipfilter/lib/ipft_pc.c
@@ -5,7 +5,7 @@
*
* See the IPFILTER.LICENCE file for details on licencing.
*
- * Id: ipft_pc.c,v 1.10 2004/02/07 18:17:40 darrenr Exp
+ * $Id: ipft_pc.c,v 1.10.2.1 2005/12/04 09:55:10 darrenr Exp $
*/
#include "ipf.h"
#include "pcap-ipf.h"
@@ -13,7 +13,7 @@
#include "ipt.h"
#if !defined(lint)
-static const char rcsid[] = "@(#)Id: ipft_pc.c,v 1.10 2004/02/07 18:17:40 darrenr Exp";
+static const char rcsid[] = "@(#)$Id: ipft_pc.c,v 1.10.2.1 2005/12/04 09:55:10 darrenr Exp $";
#endif
struct llc {
@@ -162,10 +162,19 @@ static int pcap_close()
static int pcap_read_rec(rec)
struct pcap_pkthdr *rec;
{
- int n, p;
+ int n, p, i;
+ char *s;
- if (read(pfd, (char *)rec, sizeof(*rec)) != sizeof(*rec))
- return -2;
+ s = (char *)rec;
+ n = sizeof(*rec);
+
+ while (n > 0) {
+ i = read(pfd, (char *)rec, sizeof(*rec));
+ if (i <= 0)
+ return -2;
+ s += i;
+ n -= i;
+ }
if (swapped) {
rec->ph_clen = SWAPLONG(rec->ph_clen);
@@ -178,6 +187,8 @@ struct pcap_pkthdr *rec;
if (!n || n < 0)
return -3;
+ if (p < 0 || p > 65536)
+ return -4;
return p;
}
@@ -224,7 +235,7 @@ int cnt, *dir;
struct pcap_pkthdr rec;
struct llc *l;
char *s, ty[4];
- int i, n;
+ int i, j, n;
l = llcp;
@@ -238,8 +249,14 @@ int cnt, *dir;
bufp = realloc(bufp, i);
s = bufp;
- if (read(pfd, s, i) != i)
- return -2;
+ for (j = i, n = 0; j > 0; ) {
+ n = read(pfd, s, j);
+ if (n <= 0)
+ return -2;
+ j -= n;
+ s += n;
+ }
+ s = bufp;
i -= l->lc_sz;
s += l->lc_to;
OpenPOWER on IntegriCloud