tcpdump mailing list archives

BUG: pcap_fopen_offline doesn't work with pcap_next [patch]


From: Dustin Spicuzza <dustin () virtualroadside com>
Date: Tue, 11 Aug 2009 17:26:29 -0400

In git, pcap_fopen_offline (and consequently, any of the other savefile
opens) doesn't work with pcap_next because the oneshot_op is not set to
anything.

One can remedy this by using pcap_create_common to create the pcap_t
instead of doing it manually. Of course, the 'source' isn't set
properly... but it doesn't segfault in any case, so thats a positive thing.

Dustin



-- 
Innovation is just a problem away
diff --git a/savefile.c b/savefile.c
old mode 100644
new mode 100755
index e3687da..431de08
--- a/savefile.c
+++ b/savefile.c
@@ -1361,13 +1361,9 @@ pcap_fopen_offline(FILE *fp, char *errbuf)
        bpf_u_int32 magic;
        int linklen;
 
-       p = (pcap_t *)malloc(sizeof(*p));
-       if (p == NULL) {
-               strlcpy(errbuf, "out of swap", PCAP_ERRBUF_SIZE);
+       p = pcap_create_common( "", errbuf );
+       if (p == NULL)
                return (NULL);
-       }
-
-       memset((char *)p, 0, sizeof(*p));
 
        amt_read = fread((char *)&hdr, 1, sizeof(hdr), fp);
        if (amt_read != sizeof(hdr)) {

Attachment: signature.asc
Description: OpenPGP digital signature


Current thread: