diff options
author | Francois-Xavier Le Bail <fx.lebail@yahoo.com> | 2015-10-19 21:47:49 +0200 |
---|---|---|
committer | Francois-Xavier Le Bail <fx.lebail@yahoo.com> | 2015-10-24 19:44:54 +0200 |
commit | d81eb812e679d3f2b4f025cc729b415203889377 (patch) | |
tree | 9d010e8f41f195aebde7f80eeb1294a20d97449e /sf-pcap.c | |
parent | 8dfa75fad7c0743418a5998b7d79a2a5f215986f (diff) | |
download | libpcap-d81eb812e679d3f2b4f025cc729b415203889377.tar.gz |
Add file capture length sanity check for pcap savefiles
Moreover:
Harmonize the invalid packet capture length error message.
Diffstat (limited to 'sf-pcap.c')
-rw-r--r-- | sf-pcap.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -232,6 +232,14 @@ pcap_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf, return NULL; } + if (hdr.snaplen > MAXIMUM_SNAPLEN) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "invalid file capture length %u, bigger than " + "maximum of %u", hdr.snaplen, MAXIMUM_SNAPLEN); + *err = 1; + return NULL; + } + /* * OK, this is a good pcap file. * Allocate a pcap_t for it. @@ -518,8 +526,8 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) if (hdr->caplen > MAXIMUM_SNAPLEN) { snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "bogus savefile header: capture length %u, bigger " - "than maximum of %u", hdr->caplen, MAXIMUM_SNAPLEN); + "invalid packet capture length %u, bigger than " + "maximum of %u", hdr->caplen, MAXIMUM_SNAPLEN); return (-1); } |