Changeset b5a23b3


Ignore:
Timestamp:
01/19/10 15:35:02 (11 years ago)
Author:
Shane Alcock <salcock@…>
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:
c2afda6
Parents:
6e90062
Message:
  • Fixed bug where a packet with zero bytes of payload would result in pcapfile_read_packet returning an EOF indicator.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_pcapfile.c

    r15e9390 rb5a23b3  
    279279        int err;
    280280        uint32_t flags = 0;
    281        
     281        size_t bytes_to_read = 0;
     282
    282283        assert(libtrace->format_data);
    283284
     
    303304                return 0;
    304305        }
    305        
    306         assert(swapl(libtrace,((libtrace_pcapfile_pkt_hdr_t*)packet->buffer)->caplen)<LIBTRACE_PACKET_BUFSIZE);
    307 
     306
     307        bytes_to_read = swapl(libtrace,((libtrace_pcapfile_pkt_hdr_t*)packet->buffer)->caplen);
     308
     309        assert(bytes_to_read < LIBTRACE_PACKET_BUFSIZE);
     310
     311        /* If there is no payload to read, do not ask wandio_read to try and
     312         * read zero bytes - we'll just get back a zero that we will
     313         * misinterpret as EOF! */
     314        if (bytes_to_read == 0) {
     315                return sizeof(libtrace_pcapfile_pkt_hdr_t);
     316        }
    308317
    309318        err=wandio_read(libtrace->io,
     
    326335        }
    327336       
    328         return sizeof(libtrace_pcapfile_pkt_hdr_t)
    329                 +swapl(libtrace,((libtrace_pcapfile_pkt_hdr_t*)packet->buffer)->caplen);
     337        return sizeof(libtrace_pcapfile_pkt_hdr_t) + bytes_to_read;
    330338}
    331339
Note: See TracChangeset for help on using the changeset viewer.