C compilers support zero-length arrays.
Add in TCHECK calls when dissecting stuff in a BGP notification.
#ifndef lint
static const char rcsid[] =
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.65 2003-05-30 11:09:39 hannes Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.66 2003-06-03 22:15:58 guy Exp $";
#endif
#include <tcpdump-stdinc.h>
#endif
#include <tcpdump-stdinc.h>
u_int8_t bgpn_type;
u_int8_t bgpn_major;
u_int8_t bgpn_minor;
u_int8_t bgpn_type;
u_int8_t bgpn_major;
u_int8_t bgpn_minor;
- u_int8_t bgpn_data[0]; /* data should follow */
};
#define BGP_NOTIFICATION_SIZE 21 /* unaligned */
};
#define BGP_NOTIFICATION_SIZE 21 /* unaligned */
{
struct bgp_notification bgpn;
int hlen;
{
struct bgp_notification bgpn;
int hlen;
TCHECK2(dat[0], BGP_NOTIFICATION_SIZE);
memcpy(&bgpn, dat, BGP_NOTIFICATION_SIZE);
TCHECK2(dat[0], BGP_NOTIFICATION_SIZE);
memcpy(&bgpn, dat, BGP_NOTIFICATION_SIZE);
/* draft-ietf-idr-cease-subcode-02 mentions optionally 7 bytes
* for the maxprefix subtype, which may contain AFI, SAFI and MAXPREFIXES
*/
/* draft-ietf-idr-cease-subcode-02 mentions optionally 7 bytes
* for the maxprefix subtype, which may contain AFI, SAFI and MAXPREFIXES
*/
- if(bgpn.bgpn_minor == BGP_NOTIFY_MINOR_CEASE_MAXPRFX && length >= BGP_NOTIFICATION_SIZE + 7)
+ if(bgpn.bgpn_minor == BGP_NOTIFY_MINOR_CEASE_MAXPRFX && length >= BGP_NOTIFICATION_SIZE + 7) {
+ datap = dat + BGP_NOTIFICATION_SIZE;
+ TCHECK2(*datap, 7);
printf(", AFI %s (%u), SAFI %s (%u), Max Prefixes: %u",
printf(", AFI %s (%u), SAFI %s (%u), Max Prefixes: %u",
- tok2str(bgp_afi_values, "Unknown", EXTRACT_16BITS(&bgpn.bgpn_data)),
- EXTRACT_16BITS(&bgpn.bgpn_data),
- tok2str(bgp_safi_values, "Unknown", *(bgpn.bgpn_data+2)),
- *(bgpn.bgpn_data+2),
- EXTRACT_32BITS(&bgpn.bgpn_data+3));
+ tok2str(bgp_afi_values, "Unknown", EXTRACT_16BITS(datap)),
+ EXTRACT_16BITS(datap),
+ tok2str(bgp_safi_values, "Unknown", *(datap+2)),
+ *(datap+2),
+ EXTRACT_32BITS(datap+3));
+ }