Changeset c69aecb for lib/format_erf.c


Ignore:
Timestamp:
09/30/14 15:17:06 (7 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, 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:
3c54095
Parents:
525d09d
Message:

Handle incomplete file reads in libtrace formats

Some file read function calls assumed that the full amount that was
asked for will be read from the file, which is not necessarily true
especially if the file was truncated.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_erf.c

    rc70f59f rc69aecb  
    480480                                        packet->buffer,
    481481                                        (size_t)dag_record_size)) == -1) {
    482                 trace_set_err(libtrace,errno,"read(%s)",
    483                                 libtrace->uridata);
     482                trace_set_err(libtrace,errno,"reading ERF file");
    484483                return -1;
    485484        }
     
    488487                return 0;
    489488        }
     489
     490        if (numbytes < (int)dag_record_size) {
     491                trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Incomplete ERF header");
     492                return -1;
     493        }
    490494
    491495        rlen = ntohs(((dag_record_t *)packet->buffer)->rlen);
     
    522526                return -1;
    523527        }
     528
     529        if (numbytes < (int)size) {
     530                trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Incomplete ERF record");
     531                return -1;
     532        }
    524533       
    525534        if (erf_prepare_packet(libtrace, packet, packet->buffer,
Note: See TracChangeset for help on using the changeset viewer.