From 2693e1d1081ac8a5f3cf15b5961d0229775e25e6 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Mon, 11 May 2015 19:40:59 -0700 Subject: In the name of God and all that is holy, don't do that. http://www.bitterfilms.com/rejected.html 1) There is *NO* guarantee that you can safely dereference a misaligned pointer. 2) There is *NO* guarantee that you are running on a little-endian machine, so that an attempt to fetch a 32-bit integer through such a pointer will fetch it in little-endian form. Instead, fetch it using tvb_get_letohl(), which 1) doesn't care about alignment and 2) always fetches in little-endian order. Change-Id: I44721cbf3c4456797990cc741836c9dd8c6c3696 Reviewed-on: https://code.wireshark.org/review/8423 Reviewed-by: Guy Harris --- epan/dissectors/packet-lbmc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'epan/dissectors/packet-lbmc.c') diff --git a/epan/dissectors/packet-lbmc.c b/epan/dissectors/packet-lbmc.c index 40203adc50..46fd8537e8 100644 --- a/epan/dissectors/packet-lbmc.c +++ b/epan/dissectors/packet-lbmc.c @@ -10075,8 +10075,6 @@ static int dissect_msg_properties(tvbuff_t * tvb, int offset, packet_info * pinf proto_item * field_item = NULL; proto_tree * field_tree = NULL; guint32 magic; - guint32 * magic_ptr = NULL; - char magic_char[4]; guint16 num_fields; guint16 idx; guint encoding; @@ -10084,9 +10082,7 @@ static int dissect_msg_properties(tvbuff_t * tvb, int offset, packet_info * pinf int data_length; proto_item * magic_item = NULL; - tvb_memcpy(tvb, (void *)magic_char, offset + O_LBM_MSG_PROPERTIES_DATA_T_MAGIC, 4); - magic_ptr = (guint32 *)magic_char; - magic = *magic_ptr; + magic = tvb_get_letohl(tvb, offset + O_LBM_MSG_PROPERTIES_DATA_T_MAGIC); encoding = ENC_LITTLE_ENDIAN; if (magic == LBM_MSG_PROPERTIES_MAGIC) { -- cgit v1.2.3