Ignore:
Timestamp:
07/02/08 23:47:26 (13 years ago)
Author:
Scott Raynel <smr26@…>
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:
ab25522
Parents:
11c0f44
Message:

Don't use sizeof(struct libtrace_linux_sll_t) and instead compute the
header length based on the contents of the header. This fixes a bug
visible via trace_get_payload_from_meta() which returns the correct
pointer but an incorrect remaining byte count.

This bug may also affect demote_packet() but this hasn't been looked at
yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/protocols_pktmeta.c

    r35782f6 r41c254d  
    2121                uint16_t *type, uint32_t *remaining)
    2222{
    23         libtrace_sll_header_t *sll;
    24 
    25         sll = (libtrace_sll_header_t*) link;
    26 
    27         if (remaining) {
    28                 if (*remaining <= sizeof(*sll)) {
    29                         *remaining = 0;
    30                         return NULL;
    31                 }
    32                 *remaining-=sizeof(*sll);
     23        libtrace_sll_header_t *sll = (libtrace_sll_header_t*) link;
     24
     25        /* Determine SLL header length */
     26        uint32_t hlen = ntohs(sll->halen) + (sizeof(uint16_t) * 4);
     27
     28        if (remaining) {
     29                if (*remaining <= hlen) {
     30                        *remaining = 0;
     31                        return NULL;
     32                }
     33                *remaining -= hlen;
    3334        }
    3435
    3536        if (type) *type = ntohs(sll->hatype);
    3637
    37         return (void*)((char*)sll+sizeof(*sll));
     38        return (void*) ((char*)sll + hlen);
    3839
    3940}
Note: See TracChangeset for help on using the changeset viewer.