aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-04-08 10:57:59 -0700
committerGuy Harris <guy@alum.mit.edu>2014-04-08 17:58:30 +0000
commitbeb4876cb4dda2b9964c223041386e5e6e33a31e (patch)
treefd4aa580d29359837132b0e2b270d0f2b0c1a6b2 /epan
parent0f0c079226d588e6dc181160199f9a08e55e4a9e (diff)
Don't assume the data pointed to by an address structure is aligned.
And don't assume you can dereference the pointer nonetheless; that doesn't work on SPARC, for example - you get an unaligned-access trap. Instead, use pntoh32() to fetch IPv4 address values from the address structures. While we're at it, just use guint32 for those addresses; we don't need in_addr_t. Change-Id: I84e6c653fe33b1bc6e67d9097ce423b82f1eb0c8 Reviewed-on: https://code.wireshark.org/review/1024 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-lbmr.c15
-rw-r--r--epan/dissectors/packet-lbtrm.c19
2 files changed, 12 insertions, 22 deletions
diff --git a/epan/dissectors/packet-lbmr.c b/epan/dissectors/packet-lbmr.c
index 47b4543e4a..32cf854c02 100644
--- a/epan/dissectors/packet-lbmr.c
+++ b/epan/dissectors/packet-lbmr.c
@@ -25,8 +25,6 @@
#include "config.h"
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
-#else
- typedef unsigned int in_addr_t;
#endif
#if HAVE_WINSOCK2_H
#include <winsock2.h>
@@ -44,6 +42,7 @@
#include <epan/wmem/wmem.h>
#include <epan/to_str.h>
#include <wsutil/inet_aton.h>
+#include <wsutil/pint.h>
#include "packet-lbm.h"
#include "packet-lbtru.h"
#include "packet-lbtrm.h"
@@ -2043,17 +2042,13 @@ static void lbmr_tag_free_cb(void * record)
static gboolean lbmr_match_packet(packet_info * pinfo, const lbmr_tag_entry_t * entry)
{
- in_addr_t dest_addr;
- in_addr_t src_addr;
- in_addr_t dest_addr_h;
- in_addr_t src_addr_h;
+ guint32 dest_addr_h;
+ guint32 src_addr_h;
if (pinfo->dst.type != AT_IPv4 || pinfo->src.type != AT_IPv4)
return (FALSE);
- dest_addr = *((in_addr_t *)pinfo->dst.data);
- dest_addr_h = g_ntohl(dest_addr);
- src_addr = *((in_addr_t *)pinfo->src.data);
- src_addr_h = g_ntohl(src_addr);
+ dest_addr_h = pntoh32(pinfo->dst.data);
+ src_addr_h = pntoh32(pinfo->src.data);
if (IN_MULTICAST(dest_addr_h))
{
diff --git a/epan/dissectors/packet-lbtrm.c b/epan/dissectors/packet-lbtrm.c
index d4f97f9c5f..ee8f512a25 100644
--- a/epan/dissectors/packet-lbtrm.c
+++ b/epan/dissectors/packet-lbtrm.c
@@ -25,8 +25,6 @@
#include "config.h"
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
-#else
- typedef unsigned int in_addr_t;
#endif
#if HAVE_WINSOCK2_H
#include <winsock2.h>
@@ -43,6 +41,7 @@
#include <epan/conversation.h>
#include <epan/to_str.h>
#include <wsutil/inet_aton.h>
+#include <wsutil/pint.h>
#include "packet-lbm.h"
#include "packet-lbtrm.h"
@@ -742,16 +741,14 @@ static char * lbtrm_tag_find(packet_info * pinfo)
{
guint idx;
lbtrm_tag_entry_t * tag = NULL;
- in_addr_t dest_addr;
- in_addr_t dest_addr_h;
+ guint32 dest_addr_h;
if (!lbtrm_use_tag)
{
return (NULL);
}
- dest_addr = *((in_addr_t *)pinfo->dst.data);
- dest_addr_h = g_ntohl(dest_addr);
+ dest_addr_h = pntoh32(pinfo->dst.data);
for (idx = 0; idx < lbtrm_tag_count; ++idx)
{
tag = &(lbtrm_tag_entry[idx]);
@@ -1531,8 +1528,7 @@ static int dissect_lbtrm(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
static gboolean test_lbtrm_packet(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void * user_data)
{
- in_addr_t dest_addr;
- in_addr_t dest_addr_h;
+ guint32 dest_addr_h;
gboolean valid_packet = FALSE;
guint8 ver_type = 0;
guint8 packet_type = 0;
@@ -1584,8 +1580,7 @@ static gboolean test_lbtrm_packet(tvbuff_t * tvb, packet_info * pinfo, proto_tre
}
else
{
- dest_addr = *((in_addr_t *)pinfo->dst.data);
- dest_addr_h = g_ntohl(dest_addr);
+ dest_addr_h = pntoh32(pinfo->dst.data);
/* Is the destination a multicast address? */
if (IN_MULTICAST(dest_addr_h))
@@ -1633,8 +1628,8 @@ void proto_reg_handoff_lbtrm(void)
{
static gboolean already_registered = FALSE;
struct in_addr addr;
- in_addr_t dest_addr_h_low;
- in_addr_t dest_addr_h_high;
+ guint32 dest_addr_h_low;
+ guint32 dest_addr_h_high;
if (!already_registered)
{