From 774a986ec07be46263e7acbbec4fbb69563a95a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Fri, 15 Dec 2017 13:41:21 +0100 Subject: epan: Add default type handling for custom column MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add default type handling in proto_custom_set() to prevent crashes when trying to use FT_IPXNET, FT_AX25 or FT_VINES items as custom columns. This will also work as a safeguard when adding new types. Change-Id: Iaf3b48aec72f0e5c10332b0e6d5f7221b0196e15 Reviewed-on: https://code.wireshark.org/review/24836 Petri-Dish: Stig Bjørlykke Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- epan/proto.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/epan/proto.c b/epan/proto.c index 646746e3a8..806d6f945e 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -5988,32 +5988,17 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence, wmem_free(NULL, str); break; - case FT_IEEE_11073_SFLOAT: - str = fvalue_to_string_repr(NULL, &finfo->value, FTREPR_DISPLAY, hfinfo->display); - g_snprintf(result+offset_r, size-offset_r, - "%s: %s", - hfinfo->name, str); - wmem_free(NULL, str); - offset_r = (int)strlen(result); - break; - - case FT_IEEE_11073_FLOAT: + default: + /* First try ftype string representation */ str = fvalue_to_string_repr(NULL, &finfo->value, FTREPR_DISPLAY, hfinfo->display); - g_snprintf(result+offset_r, size-offset_r, - "%s: %s", - hfinfo->name, str); - offset_r = (int)strlen(result); + if (!str) { + /* Default to show as bytes */ + bytes = (guint8 *)fvalue_get(&finfo->value); + str = bytes_to_str(NULL, bytes, fvalue_length(&finfo->value)); + } + offset_r += protoo_strlcpy(result+offset_r, str, size-offset_r); wmem_free(NULL, str); break; - - case FT_IPXNET: /*XXX really No column custom ?*/ - case FT_PCRE: - default: - g_error("hfinfo->type %d (%s) not handled\n", - hfinfo->type, - ftype_name(hfinfo->type)); - DISSECTOR_ASSERT_NOT_REACHED(); - break; } i++; } -- cgit v1.2.3