diff options
| author | guy <guy> | 2000-10-09 03:24:24 +0000 |
|---|---|---|
| committer | guy <guy> | 2000-10-09 03:24:24 +0000 |
| commit | 596742a577ad2c1e22ba8b70fbc63961b8c4e614 (patch) | |
| tree | 4c10bd77546a12db41fbd8aad41d40f7df98148b /print-arp.c | |
| parent | d16cf6488c6a3a8a4257311c80d5766ed8b7cdcb (diff) | |
| download | tcpdump-596742a577ad2c1e22ba8b70fbc63961b8c4e614.tar.gz | |
Some compilers may pad structures to a length that's a multiple of 2 or
4 bytes, even though no member in the structure requires such an
alignment; don't use "sizeof (struct ether_arp), explicitly #define the
header length and use that #defined value.
We don't use "struct ether_addr" in any dissectors, so there's no need
to define it in "ether.h" - and, if compilers pad it to a multiple of 4
bytes, you can't use it anyway, as it'll be 8 bytes long, not 6 bytes
long.
Diffstat (limited to 'print-arp.c')
| -rw-r--r-- | print-arp.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/print-arp.c b/print-arp.c index 26cb7cde..306801ef 100644 --- a/print-arp.c +++ b/print-arp.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.47 2000-09-24 07:42:31 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.48 2000-10-09 03:24:25 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -78,6 +78,8 @@ struct arphdr { #endif }; +#define ARP_HDRLEN 8 + /* * Ethernet Address Resolution Protocol. * @@ -98,6 +100,8 @@ struct ether_arp { #define arp_pln ea_hdr.ar_pln #define arp_op ea_hdr.ar_op +#define ETHER_ARP_HDRLEN (ARP_HDRLEN + 6 + 4 + 6 + 4) + #define SHA(ap) ((ap)->arp_sha) #define THA(ap) ((ap)->arp_tha) #define SPA(ap) ((ap)->arp_spa) @@ -125,7 +129,7 @@ arp_print(register const u_char *bp, u_int length, u_int caplen) printf("[|arp]"); return; } - if (length < sizeof(struct ether_arp)) { + if (length < ETHER_ARP_HDRLEN) { (void)printf("truncated-arp"); default_print((u_char *)ap, length); return; |
