]> The Tcpdump Group git mirrors - libpcap/commitdiff
From Dustin Spicuzza: use pcap_create_common() to allocate the pcap_t in
authorGuy Harris <[email protected]>
Wed, 12 Aug 2009 05:06:38 +0000 (22:06 -0700)
committerGuy Harris <[email protected]>
Wed, 12 Aug 2009 05:06:38 +0000 (22:06 -0700)
pcap_fopen_offline(), so that we initialize various function pointers
(not just the oneshot callback, but also functions such as the "can set
rfmon mode" function).

savefile.c

index e3687da41beae083800a968ffd19306e41882bc8..67da51fd629f82f50e0b19088ba2b584a54415c8 100644 (file)
@@ -1361,13 +1361,9 @@ pcap_fopen_offline(FILE *fp, char *errbuf)
        bpf_u_int32 magic;
        int linklen;
 
        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("(savefile)", errbuf);
+       if (p == NULL)
                return (NULL);
                return (NULL);
-       }
-
-       memset((char *)p, 0, sizeof(*p));
 
        amt_read = fread((char *)&hdr, 1, sizeof(hdr), fp);
        if (amt_read != sizeof(hdr)) {
 
        amt_read = fread((char *)&hdr, 1, sizeof(hdr), fp);
        if (amt_read != sizeof(hdr)) {