diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-01-18 13:02:15 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-01-18 21:02:40 +0000 |
commit | 050bc7d100e9846663ac2c14eadde15e9cd9fdb9 (patch) | |
tree | 29b58df68f42d396d1507e89df1e9d8631713368 | |
parent | 929d41c6856139168c441a14498210d31574de97 (diff) |
Update some comments to reflect reality.
Get rid of references to ep_ and se_ allocation in code that now uses
wmem allocation instead.
Fix API documentation of conversation_table.h routines to reflect that
as well - some APIs changed to pass wmem scopes.
Also, zbee_sec_key_hash() now takes the output buffer as an argument and
just returns it, and nobody actually uses the return value, so change it
to return void.
Change-Id: Ife1ec675a9322fd0f0be306a9d639ec17aad1c7a
Reviewed-on: https://code.wireshark.org/review/6636
Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r-- | epan/addr_resolv.c | 2 | ||||
-rw-r--r-- | epan/conversation.c | 5 | ||||
-rw-r--r-- | epan/conversation_table.h | 9 | ||||
-rw-r--r-- | epan/dissectors/packet-bacapp.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-dcerpc-nt.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-dcm.c | 8 | ||||
-rw-r--r-- | epan/dissectors/packet-spdy.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-zbee-aps.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-zbee-security.c | 16 | ||||
-rw-r--r-- | ui/qt/packet_list.cpp | 1 |
10 files changed, 29 insertions, 24 deletions
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c index a27e09a760..b7ff553aab 100644 --- a/epan/addr_resolv.c +++ b/epan/addr_resolv.c @@ -2908,8 +2908,6 @@ address_to_display(wmem_allocator_t *allocator, const address *addr) const gchar *result = solve_address_to_name(addr); if (result != NULL) { - /* unlike ep_address_to_display(), we can't assume the lifetime of the address' members - is safe, so we allocate and copy */ str = wmem_strdup(allocator, result); } else if (addr->type == AT_NONE) { diff --git a/epan/conversation.c b/epan/conversation.c index aa66996ef0..859555187e 100644 --- a/epan/conversation.c +++ b/epan/conversation.c @@ -466,7 +466,7 @@ free_data_list(gpointer value) { conversation_t *conv = (conversation_t *)value; - /* TODO: se_slist? */ + /* TODO: file scoped wmem_list? There's no singly-linked wmem_ list */ g_slist_free(conv->data_list); /* Not really necessary, but... */ @@ -482,7 +482,8 @@ conversation_cleanup(void) { /* Clean up the hash tables, but only after freeing any proto_data * that may be hanging off the conversations. - * The conversation keys are se_ allocated so we don't have to clean them up. + * The conversation keys are wmem-allocated with file scope so we + * don't have to clean them up. */ conversation_keys = NULL; if (conversation_hashtable_exact != NULL) { diff --git a/epan/conversation_table.h b/epan/conversation_table.h index 61b9ce7f39..5c5699dad5 100644 --- a/epan/conversation_table.h +++ b/epan/conversation_table.h @@ -253,18 +253,20 @@ WS_DLL_PUBLIC void dissector_hostlist_init(const char *opt_arg, void* userdata); /** Get the string representation of an address. * + * @param allocator The wmem allocator to use when allocating the string * @param addr The address. * @param resolve_names Enable name resolution. - * @return An ep_allocated string representing the address. + * @return A string representing the address. */ WS_DLL_PUBLIC const char *get_conversation_address(wmem_allocator_t *allocator, address *addr, gboolean resolve_names); /** Get the string representation of a port. * + * @param allocator The wmem allocator to use when allocating the string * @param port The port number. * @param ptype The port type. * @param resolve_names Enable name resolution. - * @return An ep_allocated string representing the port. + * @return A string representing the port. */ WS_DLL_PUBLIC const char *get_conversation_port(wmem_allocator_t *allocator, guint32 port, port_type ptype, gboolean resolve_names); @@ -279,7 +281,8 @@ WS_DLL_PUBLIC const char *get_conversation_filter(conv_item_t *conv_item, conv_d /** Get a display filter for the given hostlist. * * @param host The hostlist. - * @return An ep_allocated string representing the conversation. + * @return A string, allocated using the wmem NULL allocator, + * representing the conversation. */ WS_DLL_PUBLIC const char *get_hostlist_filter(hostlist_talker_t *host); diff --git a/epan/dissectors/packet-bacapp.c b/epan/dissectors/packet-bacapp.c index bc4dd2e479..1058edf70b 100644 --- a/epan/dissectors/packet-bacapp.c +++ b/epan/dissectors/packet-bacapp.c @@ -5093,7 +5093,7 @@ register_bacapp_stat_trees(void) bacapp_stats_tree_instanceid, bacapp_instanceid_stats_tree_init, NULL); } -/* 'data' must be ep_ allocated */ +/* 'data' must be allocated with wmem packet scope */ static gint updateBacnetInfoValue(gint whichval, const gchar *data) { diff --git a/epan/dissectors/packet-dcerpc-nt.c b/epan/dissectors/packet-dcerpc-nt.c index 36518c4462..d8a95fa97d 100644 --- a/epan/dissectors/packet-dcerpc-nt.c +++ b/epan/dissectors/packet-dcerpc-nt.c @@ -873,8 +873,8 @@ static void init_pol_hash(void) /* Initialise hash table */ if (pol_hash) { - /* Everything in the table is se_ allocated so there's no - * need to go through and free it all. + /* Everything in the table is allocated with wmem file + * scope so there's no need to go through and free it all. */ g_hash_table_destroy(pol_hash); } diff --git a/epan/dissectors/packet-dcm.c b/epan/dissectors/packet-dcm.c index fa57050e7e..3b69ed6759 100644 --- a/epan/dissectors/packet-dcm.c +++ b/epan/dissectors/packet-dcm.c @@ -36,6 +36,10 @@ * - Read private tags from configuration and parse in capture * - dissect_dcm_heuristic() to return proper data type * + * September 2013 - Pascal Quantin + * + * - Replace all ep_ and se_ allocation with wmem_ allocations + * * February 2013 - Stefan Allers * * - Support for dissection of Extended Negotiation (Query/Retrieve @@ -6099,7 +6103,7 @@ dissect_dcm_tag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean is_sequence = FALSE; /* True for Sequence Tags */ gboolean is_item = FALSE; /* True for Sequence Item Tags */ - *tag_description = NULL; /* Reset description. It's ep_ memory, so not really bad*/ + *tag_description = NULL; /* Reset description. It's wmem packet scope memory, so not really bad*/ tag_value = (gchar *)wmem_alloc0(wmem_packet_scope(), MAX_BUF_LEN); @@ -6351,7 +6355,7 @@ dissect_dcm_tag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean local_end_of_seq_or_item = FALSE; gboolean is_first_desc = TRUE; - const gchar *item_description = NULL; /* Will be allocated as ep_ memory in dissect_dcm_tag() */ + const gchar *item_description = NULL; /* Will be allocated as wmem packet scope memory in dissect_dcm_tag() */ if (vl == 0xFFFFFFFF) { /* Undefined length */ diff --git a/epan/dissectors/packet-spdy.c b/epan/dissectors/packet-spdy.c index b9a0277dfa..6a0a63dfe3 100644 --- a/epan/dissectors/packet-spdy.c +++ b/epan/dissectors/packet-spdy.c @@ -948,7 +948,7 @@ body_dissected: * Performs header decompression. * * The returned buffer is automatically scoped to the lifetime of the capture - * (via se_memdup()). + * (via wmem_memdup() with file scope). */ #define DECOMPRESS_BUFSIZE 16384 diff --git a/epan/dissectors/packet-zbee-aps.c b/epan/dissectors/packet-zbee-aps.c index b28393ac7f..cabd99771c 100644 --- a/epan/dissectors/packet-zbee-aps.c +++ b/epan/dissectors/packet-zbee-aps.c @@ -1290,6 +1290,10 @@ dissect_zbee_aps_transport_key(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree /* Create an empty key ring for this pan. Use g_malloc0() because we must free * GSLists after a capture is closed and wireshark frees seasonal memory * with se_free_all() before calling the registered init routine. + * + * XXX - we don't use seasonal memory any more, and libwireshark + * just does wmem_enter_file_scope() before calling registered init + * routines; does this still apply? */ nwk_keyring = (GSList **)g_malloc0(sizeof(GSList*)); g_hash_table_insert(zbee_table_nwk_keyring, diff --git a/epan/dissectors/packet-zbee-security.c b/epan/dissectors/packet-zbee-security.c index ea2fd1e3bc..c2312a1b1f 100644 --- a/epan/dissectors/packet-zbee-security.c +++ b/epan/dissectors/packet-zbee-security.c @@ -47,7 +47,7 @@ /* Helper Functions */ #ifdef HAVE_LIBGCRYPT -static guint8 * zbee_sec_key_hash(guint8 *, guint8, guint8 *); +static void zbee_sec_key_hash(guint8 *, guint8, guint8 *); static void zbee_sec_make_nonce (zbee_security_packet *, guint8 *); static gboolean zbee_sec_decrypt_payload(zbee_security_packet *, const gchar *, const gchar, guint8 *, guint, guint, guint8 *); @@ -1213,18 +1213,15 @@ zbee_sec_hash(guint8 *input, guint input_len, guint8 *output) * ipad = 0x36 repeated. * opad = 0x5c repeated. * H() = ZigBee Cryptographic Hash (B.1.3 and B.6). - * - * The output of this function is an ep_alloced buffer containing - * the key-hashed output, and is garaunteed never to return NULL. * PARAMETERS - * guint8 *key - ZigBee Security Key (must be ZBEE_SEC_CONST_KEYSIZE) in length. - * guint8 input - ZigBee CCM* Nonce (must be ZBEE_SEC_CONST_NONCE_LEN) in length. - * packet_info *pinfo - pointer to packet information fields + * guint8 *key - ZigBee Security Key (must be ZBEE_SEC_CONST_KEYSIZE) in length. + * guint8 input - ZigBee CCM* Nonce (must be ZBEE_SEC_CONST_NONCE_LEN) in length. + * guint8 *hash_out - buffer into which the key-hashed output is placed * RETURNS - * guint8* + * void *--------------------------------------------------------------- */ -static guint8 * +static void zbee_sec_key_hash(guint8 *key, guint8 input, guint8 *hash_out) { guint8 hash_in[2*ZBEE_SEC_CONST_BLOCKSIZE]; @@ -1244,7 +1241,6 @@ zbee_sec_key_hash(guint8 *key, guint8 input, guint8 *hash_out) zbee_sec_hash(hash_out, ZBEE_SEC_CONST_BLOCKSIZE+1, hash_in+ZBEE_SEC_CONST_BLOCKSIZE); /* Hash the contents of hash_in to get the final result. */ zbee_sec_hash(hash_in, 2*ZBEE_SEC_CONST_BLOCKSIZE, hash_out); - return hash_out; } /* zbee_sec_key_hash */ #else /* HAVE_LIBGCRYPT */ gboolean diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index 43aab835a8..d3a4af5b35 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -739,7 +739,6 @@ QString &PacketList::getFilterFromRowAndColumn() */ if (strlen(cap_file_->cinfo.col_expr.col_expr[ctx_column_]) != 0 && strlen(cap_file_->cinfo.col_expr.col_expr_val[ctx_column_]) != 0) { - /* leak a little but safer than ep_ here */ if (cap_file_->cinfo.col_fmt[ctx_column_] == COL_CUSTOM) { header_field_info *hfi = proto_registrar_get_byname(cap_file_->cinfo.col_custom_field[ctx_column_]); if (hfi->parent == -1) { |