From c1d8dfccb9e54247e5c78c3930488ecd9606011f Mon Sep 17 00:00:00 2001 From: Bill Meier Date: Mon, 23 Apr 2012 01:36:57 +0000 Subject: [PATCH] It's not kosher to alloc and init a GArray ourselves instead of calling g_array_new(). Fixes Bug #7138 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7138) A puzzle: why did the buildbot fuzz-testing only start failing on this on 04/18/2012 since the bug has existed for quite some time ? svn path=/trunk/; revision=42200 --- epan/dissectors/packet-diameter.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/epan/dissectors/packet-diameter.c b/epan/dissectors/packet-diameter.c index d546ace198..140734e15a 100644 --- a/epan/dissectors/packet-diameter.c +++ b/epan/dissectors/packet-diameter.c @@ -180,9 +180,7 @@ typedef struct _proto_avp_t { static const char* simple_avp(diam_ctx_t*, diam_avp_t*, tvbuff_t*); -static const value_string no_vs[] = {{0, NULL} }; -static GArray no_garr = { (void*)no_vs, 0 }; -static diam_vnd_t unknown_vendor = { 0xffffffff, &no_garr, NULL, &no_garr }; +static diam_vnd_t unknown_vendor = { 0xffffffff, NULL, NULL, NULL }; static diam_vnd_t no_vnd = { 0, NULL, NULL, NULL }; static diam_avp_t unknown_avp = {0, &unknown_vendor, simple_avp, simple_avp, -1, -1, NULL }; static GArray* all_cmds; @@ -1391,6 +1389,11 @@ strcase_equal(gconstpointer ka, gconstpointer kb) } +/* Note: Dynamic "value string arrays" (e.g., vs_cmds, vs_avps, ...) are constructed using */ +/* "zero-terminated" GArrays so that they will have the same form as standard */ +/* value_string arrays created at compile time. Since the last entry in a */ +/* value_string array must be {0, NULL}, we are assuming that NULL == 0 (hackish). */ + static int dictionary_load(void) { @@ -1418,6 +1421,8 @@ dictionary_load(void) dictionary.vnds = pe_tree_create(EMEM_TREE_TYPE_RED_BLACK,"diameter_vnds"); dictionary.avps = pe_tree_create(EMEM_TREE_TYPE_RED_BLACK,"diameter_avps"); + unknown_vendor.vs_cmds = g_array_new(TRUE,TRUE,sizeof(value_string)); + unknown_vendor.vs_avps = g_array_new(TRUE,TRUE,sizeof(value_string)); no_vnd.vs_cmds = g_array_new(TRUE,TRUE,sizeof(value_string)); no_vnd.vs_avps = g_array_new(TRUE,TRUE,sizeof(value_string));