diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-07-19 23:25:30 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-07-19 23:25:30 +0000 |
commit | 7d9529531983cee80e4de5aba4060218a808f0e4 (patch) | |
tree | 2633c63c0ce14d3e51d8976512f1a7dae43909fd /lib/libpcap/savefile.c | |
parent | 4ca7f4445b8c72afb1e9129073f0e5036f1bcef7 (diff) |
if pcap_dump_open() specified a snaplen of -1, make sure pcap_open_offline() does not malloc -1, but uses max snaplen; pointed out by mts@nfr.net
Diffstat (limited to 'lib/libpcap/savefile.c')
-rw-r--r-- | lib/libpcap/savefile.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/libpcap/savefile.c b/lib/libpcap/savefile.c index 2e70b05a577..07897d9a593 100644 --- a/lib/libpcap/savefile.c +++ b/lib/libpcap/savefile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: savefile.c,v 1.5 1998/07/14 00:14:05 deraadt Exp $ */ +/* $OpenBSD: savefile.c,v 1.6 1999/07/19 23:25:29 deraadt Exp $ */ /* * Copyright (c) 1993, 1994, 1995 @@ -178,7 +178,13 @@ pcap_open_offline(char *fname, char *errbuf) break; } + if (p->bufsize < 0) + p->bufsize = BPF_MAXBUFSIZE; p->sf.base = (u_char *)malloc(p->bufsize + BPF_ALIGNMENT); + if (p->sf.base == NULL) { + strlcpy(errbuf, "out of swap", PCAP_ERRBUFF_SIZE); + goto bad; + } p->buffer = p->sf.base + BPF_ALIGNMENT - (linklen % BPF_ALIGNMENT); p->sf.version_major = hdr.version_major; p->sf.version_minor = hdr.version_minor; |