From fe8d897e2557f109b252ce83421d929c1ac039c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Sun, 29 Oct 2017 12:21:27 +0000 Subject: sizeof(buf) is not what you want here MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iaf3463006b93c9acdc27f59fcbbea92df1d2fd7d Reviewed-on: https://code.wireshark.org/review/24164 Petri-Dish: João Valverde Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde --- epan/address_types.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'epan/address_types.c') diff --git a/epan/address_types.c b/epan/address_types.c index f73ed932da..f416bd168d 100644 --- a/epan/address_types.c +++ b/epan/address_types.c @@ -418,7 +418,7 @@ static int eui64_addr_to_str(const address* addr, gchar *buf, int buf_len _U_) { buf = bytes_to_hexstr_punct(buf, (const guint8 *)addr->data, 8, ':'); *buf = '\0'; /* NULL terminate */ - return sizeof(buf) + 1; + return (int)(strlen(buf)+1); } static int eui64_str_len(const address* addr _U_) @@ -442,12 +442,9 @@ ib_addr_to_str(const address *addr, gchar *buf, int buf_len) } /* this is a LID (16 bits) */ - guint16 lid_number; - - memcpy((void *)&lid_number, addr->data, sizeof lid_number); - g_snprintf(buf,buf_len,"LID: %u",lid_number); + g_snprintf(buf,buf_len,"LID: %u", *(guint16 *)addr->data); - return sizeof(buf) + 1; // XXX this looks all kinds of wrong + return (int)(strlen(buf)+1); } static int ib_str_len(const address* addr _U_) -- cgit v1.2.3