diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2017-12-15 13:41:21 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-12-15 20:59:04 +0000 |
commit | 774a986ec07be46263e7acbbec4fbb69563a95a1 (patch) | |
tree | 6ecf583c2b555f41c48dededec256437ac731842 | |
parent | bdb6baa7405d259fa2cd2f6f7d2fb21e13315885 (diff) |
epan: Add default type handling for custom column
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 <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r-- | epan/proto.c | 31 |
1 files 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++; } |