Changeset 1b95fd0


Ignore:
Timestamp:
05/23/06 14:56:06 (15 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:
63f4967
Parents:
f6c2d8d
Message:

Don't wander off the end of the packet when the packet was prematurely snapped
when looking at packets that were snapped before the end of the IPv6 header
when looking for the source/dest port.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/protocols.c

    r77285d9 r1b95fd0  
    337337{
    338338        void *transport;
    339         uint8_t dummy;
     339        uint8_t dummy_proto;
    340340        uint16_t ethertype;
    341341        void *link;
    342 
    343         if (!proto) proto=&dummy;
    344 
    345         if (remaining)
    346                 *remaining = trace_get_capture_length(packet);
     342        uint32_t dummy_remaining;
     343
     344        if (!proto) proto=&dummy_proto;
     345
     346        if (!remaining) remaining=&dummy_remaining;
     347
     348        *remaining = trace_get_capture_length(packet);
    347349
    348350        link=trace_get_link(packet);
     
    500502DLLEXPORT uint16_t trace_get_source_port(const libtrace_packet_t *packet)
    501503{
     504        uint32_t remaining;
    502505        struct ports_t *port =
    503506                (struct ports_t*)trace_get_transport((libtrace_packet_t*)packet,
    504                         NULL, NULL);
     507                        NULL, &remaining);
     508
     509        /* snapped too early */
     510        if (remaining<2)
     511                return 0;
    505512
    506513        if (port)
Note: See TracChangeset for help on using the changeset viewer.