diff options
author | Peter Wu <peter@lekensteyn.nl> | 2015-09-08 11:11:19 +0200 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2015-09-13 02:38:19 +0000 |
commit | 33570f81b55b3ac846e2b16836b5a0b3083de1b3 (patch) | |
tree | b003bfd10505ef85c829c42667173e8841413f87 /ui/gtk/addr_resolution_dlg.c | |
parent | 648cf995b108ae2cb6df83e1144b32f34ffb8028 (diff) |
Fix misaligned read and buffer overrun
Ethernet addresses are only 6 bytes in size, reading it as a 64-bit
integer is invalid. Use unsigned 8-bit integers instead.
Caught by UBSAN and Address Sanitizer. Trigger via the Statistics menu
Resolved Addresses (Qt) or Show address resolution (GTK).
Change-Id: I628ff7cce0ea4f4e378c7968cd79a0ae34cdd20b
Reviewed-on: https://code.wireshark.org/review/10443
Reviewed-by: ronnie sahlberg <ronniesahlberg@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'ui/gtk/addr_resolution_dlg.c')
-rw-r--r-- | ui/gtk/addr_resolution_dlg.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/ui/gtk/addr_resolution_dlg.c b/ui/gtk/addr_resolution_dlg.c index cca7db805c..ff693fc674 100644 --- a/ui/gtk/addr_resolution_dlg.c +++ b/ui/gtk/addr_resolution_dlg.c @@ -50,16 +50,12 @@ eth_hash_to_texbuff(gpointer key, gpointer value, gpointer user_data) { gchar string_buff[ADDRESS_STR_MAX]; GtkTextBuffer *buffer = (GtkTextBuffer*)user_data; - gint64 eth_as_gint64 = *(gint64*)key; + guint8 *eth_addr = (guint8*)key; hashether_t* tp = (hashether_t*)value; g_snprintf(string_buff, ADDRESS_STR_MAX, "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X Status: %u %s %s\n", - (guint8)(eth_as_gint64>>40&0xff), - (guint8)(eth_as_gint64>>32&0xff), - (guint8)((eth_as_gint64>>24)&0xff), - (guint8)((eth_as_gint64>>16)&0xff), - (guint8)((eth_as_gint64>>8)&0xff), - (guint8)(eth_as_gint64&0xff), + eth_addr[0], eth_addr[1], eth_addr[2], + eth_addr[3], eth_addr[4], eth_addr[5], get_hash_ether_status(tp), get_hash_ether_hexaddr(tp), get_hash_ether_resolved_name(tp)); @@ -85,15 +81,11 @@ wka_hash_to_texbuff(gpointer key, gpointer value, gpointer user_data) gchar string_buff[ADDRESS_STR_MAX]; GtkTextBuffer *buffer = (GtkTextBuffer*)user_data; gchar *name = (gchar *)value; - gint64 eth_as_gint64 = *(gint64*)key; + guint8 *eth_addr = (guint8*)key; g_snprintf(string_buff, ADDRESS_STR_MAX, "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X %s\n", - (guint8)(eth_as_gint64>>40&0xff), - (guint8)(eth_as_gint64>>32&0xff), - (guint8)((eth_as_gint64>>24)&0xff), - (guint8)((eth_as_gint64>>16)&0xff), - (guint8)((eth_as_gint64>>8)&0xff), - (guint8)(eth_as_gint64&0xff), + eth_addr[0], eth_addr[1], eth_addr[2], + eth_addr[3], eth_addr[4], eth_addr[5], name); gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1); |