diff options
author | Guy Harris <guy@alum.mit.edu> | 2018-02-03 20:10:19 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2018-02-04 04:11:00 +0000 |
commit | c2debddb2cd2ab8b0eff87ce37578c1f78f6864d (patch) | |
tree | 0cf133ca7c9ba2dc89de90c99aea563e8d30b95f /epan/dissectors/packet-icmp.c | |
parent | 676d4668c83f8c78f35098d9c4ef8851729460fc (diff) |
Don't assume address data is aligned.
The data for an address is *not* guaranteed to be aligned on any
particular boundary, so, for IPv4 addresses, don't assume it's aligned
on a 32-bit boundary - to get it in host byte order, fetch it with
pntoh32(), which fetches a 32-bit value that's in network byte order,
and isn't necessarily aligned on any particular boundary, and returns it
in host byte order.
Change-Id: Ic512ab4b1e0f2815d9f0af0e33714f456a08a45d
Reviewed-on: https://code.wireshark.org/review/25589
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/dissectors/packet-icmp.c')
-rw-r--r-- | epan/dissectors/packet-icmp.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/epan/dissectors/packet-icmp.c b/epan/dissectors/packet-icmp.c index 670640ab21..7a9e06eabd 100644 --- a/epan/dissectors/packet-icmp.c +++ b/epan/dissectors/packet-icmp.c @@ -46,6 +46,8 @@ #include <epan/capture_dissectors.h> #include <epan/proto_data.h> +#include <wsutil/pint.h> + #include "packet-ip.h" #include "packet-icmp.h" @@ -363,17 +365,19 @@ static const value_string interface_role_str[] = { #define MPLS_EXTENDED_PAYLOAD_C_TYPE 1 /* Return true if the address is in the 224.0.0.0/4 network block */ -#define is_a_multicast_addr(a) in4_addr_is_multicast(g_ntohl(a)) +#define is_a_multicast_addr(a) in4_addr_is_multicast(a) /* Return true if the address is the 255.255.255.255 broadcast address */ -#define is_a_broadcast_addr(a) \ - (g_ntohl(a) == 0xffffffff) +#define is_a_broadcast_addr(a) ((a) == 0xffffffffU) +/* + * XXX - should these be checking the address *type*, instead? + */ #define ADDR_IS_MULTICAST(addr) \ - (((addr)->len == 4) && is_a_multicast_addr(*(const guint32 *)((addr)->data))) + (((addr)->len == 4) && is_a_multicast_addr(pntoh32((addr)->data))) #define ADDR_IS_BROADCAST(addr) \ - (((addr)->len == 4) && is_a_broadcast_addr(*(const guint32 *)((addr)->data))) + (((addr)->len == 4) && is_a_broadcast_addr(pntoh32((addr)->data))) #define ADDR_IS_NOT_UNICAST(addr) \ (ADDR_IS_MULTICAST(addr) || ADDR_IS_BROADCAST(addr)) |