From 6cbbcee6b675be5e63807767ff817ca6b75b7bee Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Wed, 13 May 2009 12:57:15 -0700 Subject: [PATCH] Reject an attempt to pass an inactivated pcap_t to pcap_dump_open(), as an inactivated pcap_t doesn't have a valid link-layer type or snapshot length. --- savefile.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/savefile.c b/savefile.c index 2ee8b9c..e69a84a 100644 --- a/savefile.c +++ b/savefile.c @@ -1734,6 +1734,16 @@ pcap_dump_open(pcap_t *p, const char *fname) FILE *f; int linktype; + /* + * If this pcap_t hasn't been activated, it doesn't have a + * link-layer type, so we can't use it. + */ + if (!p->activated) { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "%s: not-yet-activated pcap_t passed to pcap_dump_open", + fname); + return (NULL); + } linktype = dlt_to_linktype(p->linktype); if (linktype == -1) { snprintf(p->errbuf, PCAP_ERRBUF_SIZE,