Changeset fe76c55 for lib/format_pcap.c


Ignore:
Timestamp:
02/21/06 16:06:17 (16 years ago)
Author:
Perry Lorier <perry@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
c1db742
Parents:
9ff68ff
Message:

More fixups for writing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_pcap.c

    r6dbc47a rfe76c55  
    167167        OUTPUT.trace.pcap = NULL;
    168168        OUTPUT.trace.dump = NULL;
    169         return 1;
     169        return 0;
    170170}
    171171
     
    254254        numbytes = pcaphdr->len;
    255255
    256         packet->header = (void *)pcaphdr;
     256        packet->buf_control = PACKET;
     257        if (!packet->buffer) {
     258                /* We only need struct pcap_pkthdr, but we have no way
     259                 * to say how much we malloc'd so that formats can determine
     260                 * if they need to malloc more, so at the moment we just
     261                 * malloc 64k
     262                 */
     263                packet->buffer=malloc(65536);
     264        }
     265        memcpy(packet->buffer,pcaphdr,sizeof(struct pcap_pkthdr));
     266        packet->header = packet->buffer;
    257267        packet->payload = (void *)pcappkt;
    258268
    259 
    260269        packet->size = numbytes + sizeof(struct pcap_pkthdr);
     270
     271        assert(pcaphdr->caplen>=0 && pcaphdr->caplen<=65536);
    261272}
    262273
     
    388399        struct pcap_pkthdr *pcapptr = 0;
    389400        pcapptr = (struct pcap_pkthdr *)packet->header;
     401        assert(pcapptr->caplen>=0 && pcapptr->caplen<=65536);
    390402        return pcapptr->caplen;
    391403}
Note: See TracChangeset for help on using the changeset viewer.