Ignore:
Timestamp:
07/04/14 11:37:25 (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:
d14e23d
Parents:
9ad7a35
Message:

Remove duplicate macros in libpacketdump

Ensure OSPF libpacketdump module won't segfault or print garbage
if a truncated OSPF header is passed into it.

Renamed 'len' field in OSPF header to 'ospf_len' to avoid
potential conflict with variables named len in libpacketdump
code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpacketdump/ip_17.c

    rc7062df r387d299  
    88#include <netdb.h>
    99
    10 #define STRUCT udp
    11 
    12 #define SAFE(x) \
    13         ((unsigned int)len>=((char*)&STRUCT->x-(char*)STRUCT+sizeof(STRUCT->x)))
    14 #define DISPLAY_EXP(x,fmt,exp) \
    15         if (SAFE(x)) \
    16                 printf(fmt,exp); \
    17         else \
    18                 return;
    19 
    20 #define DISPLAY(x,fmt) DISPLAY_EXP(x,fmt,STRUCT->x)
    21 
    22 #define DISPLAYS(x,fmt) DISPLAY_EXP(x,fmt,htons(STRUCT->x))
    23 #define DISPLAYL(x,fmt) DISPLAY_EXP(x,fmt,htonl(STRUCT->x))
    24 #define DISPLAYIP(x,fmt) DISPLAY_EXP(x,fmt,inet_ntoa(*(struct in_addr*)&STRUCT->x))
    25 
    2610
    2711DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len)
     
    2913        struct libtrace_udp *udp = (struct libtrace_udp*)packet;
    3014        printf(" UDP:");
    31         if (SAFE(source)) {
     15        if (SAFE(udp, source)) {
    3216                struct servent *ent=getservbyport(udp->source,"udp");
    3317                if(ent) {
     
    4125                return;
    4226        }
    43         if (SAFE(dest)) {
     27        if (SAFE(udp, dest)) {
    4428                struct servent *ent=getservbyport(udp->dest,"udp");
    4529                if(ent) {
     
    5438        }
    5539        printf("\n UDP:");
    56         DISPLAYS(len," Len %u");
    57         DISPLAYS(check," Checksum %u");
     40        DISPLAYS(udp, len," Len %u");
     41        DISPLAYS(udp, check," Checksum %u");
    5842        printf("\n");
    5943        if (htons(udp->source) < htons(udp->dest))
Note: See TracChangeset for help on using the changeset viewer.