Changeset 819


Ignore:
Timestamp:
05/23/06 14:56:06 (7 years ago)
Author:
perry
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
  • trunk/lib/protocols.c

    r795 r819  
    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.