diff options
author | Anders Broman <anders.broman@ericsson.com> | 2010-01-11 16:14:26 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2010-01-11 16:14:26 +0000 |
commit | 324af9e6faea22dc42c13cf7efaeef7777550c2d (patch) | |
tree | 987fbd224c57a79a89dd00ab3969dc74c2e10bb8 /epan | |
parent | 11ef8a5e0f0acf7134edf8c0b4bb1d7239994d11 (diff) |
Fix part of Bug 3917 "tvb_new_real_data is prone to memory leak"
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=3917
svn path=/trunk/; revision=31499
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-dmp.c | 30 | ||||
-rw-r--r-- | epan/dissectors/packet-ldss.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-pkcs12.c | 2 | ||||
-rw-r--r-- | epan/dissectors/pidl/mapi/request.cnf.c | 3 | ||||
-rw-r--r-- | epan/dissectors/pidl/mapi/response.cnf.c | 4 |
5 files changed, 19 insertions, 22 deletions
diff --git a/epan/dissectors/packet-dmp.c b/epan/dissectors/packet-dmp.c index cd2edf3570..df2e61cf71 100644 --- a/epan/dissectors/packet-dmp.c +++ b/epan/dissectors/packet-dmp.c @@ -2744,22 +2744,22 @@ static gint dissect_dmp_message (tvbuff_t *tvb, packet_info *pinfo, } else if (len > 0 && (dmp.body_format == FREE_TEXT || dmp.body_format == FREE_TEXT_SUBJECT)) { if (compr_alg == ALGORITHM_ZLIB) { - if ((next_tvb = tvb_uncompress (tvb, offset, len)) != NULL) { - gint zlen = tvb_length (next_tvb); - add_new_data_source (pinfo, next_tvb, "Uncompressed User data"); - tf = proto_tree_add_none_format (message_tree, - hf_message_body_uncompr, - next_tvb, 0, zlen, - "Uncompressed User data, " - "Length: %d", zlen); - field_tree = proto_item_add_subtree (tf, ett_message_body_uncompr); - proto_tree_add_item (field_tree, hf_message_body_uncompressed, - next_tvb, 0, -1, FALSE); + if ((next_tvb = tvb_child_uncompress (NULL, tvb, offset, len)) != NULL) { + gint zlen = tvb_length (next_tvb); + add_new_data_source (pinfo, next_tvb, "Uncompressed User data"); + tf = proto_tree_add_none_format (message_tree, + hf_message_body_uncompr, + next_tvb, 0, zlen, + "Uncompressed User data, " + "Length: %d", zlen); + field_tree = proto_item_add_subtree (tf, ett_message_body_uncompr); + proto_tree_add_item (field_tree, hf_message_body_uncompressed, + next_tvb, 0, -1, FALSE); } else { - tf = proto_tree_add_text (message_tree, tvb, offset, -1, - "Error: Unable to uncompress content"); - expert_add_info_format (pinfo, tf, PI_UNDECODED, PI_WARN, - "Unable to uncompress content"); + tf = proto_tree_add_text (message_tree, tvb, offset, -1, + "Error: Unable to uncompress content"); + expert_add_info_format (pinfo, tf, PI_UNDECODED, PI_WARN, + "Unable to uncompress content"); } } else if (eit != EIT_BILATERAL) { proto_tree_add_item (field_tree, hf_message_body_plain, tvb, diff --git a/epan/dissectors/packet-ldss.c b/epan/dissectors/packet-ldss.c index bfaa7d3ebe..ea8a906f3c 100644 --- a/epan/dissectors/packet-ldss.c +++ b/epan/dissectors/packet-ldss.c @@ -701,7 +701,7 @@ dissect_ldss_transfer (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Be nice and uncompress the file data. */ if (compression == COMPRESSION_GZIP) { tvbuff_t *uncomp_tvb = NULL; - uncomp_tvb = tvb_uncompress(tvb, 0, tvb_length(tvb)); + uncomp_tvb = tvb_child_uncompress(NULL, tvb, 0, tvb_length(tvb)); if (uncomp_tvb != NULL) { ti = proto_tree_add_bytes_format_value(ldss_tree, hf_ldss_file_data, uncomp_tvb, 0, tvb_length(uncomp_tvb), diff --git a/epan/dissectors/packet-pkcs12.c b/epan/dissectors/packet-pkcs12.c index 71099a439d..65e0aa1860 100644 --- a/epan/dissectors/packet-pkcs12.c +++ b/epan/dissectors/packet-pkcs12.c @@ -451,7 +451,7 @@ int PBE_decrypt_data(const char *object_identifier_id _U_, tvbuff_t *encrypted_t /* OK - so now clear_data contains the decrypted data */ - clear_tvb = tvb_new_real_data((const guint8 *)clear_data, datalen, datalen); + clear_tvb = tvb_new_child_real_data(encrypted_tvb,(const guint8 *)clear_data, datalen, datalen); tvb_set_free_cb(clear_tvb, g_free); name = g_string_new(""); diff --git a/epan/dissectors/pidl/mapi/request.cnf.c b/epan/dissectors/pidl/mapi/request.cnf.c index 911a80d0d9..4db47ebf38 100644 --- a/epan/dissectors/pidl/mapi/request.cnf.c +++ b/epan/dissectors/pidl/mapi/request.cnf.c @@ -136,10 +136,9 @@ mapi_dissect_element_EcDoRpc_request_(tvbuff_t *tvb _U_, int offset _U_, packet_ decrypted_data[i] = ptr[i] ^ 0xA5; } - decrypted_tvb = tvb_new_real_data(decrypted_data, size, reported_len); + decrypted_tvb = tvb_new_child_real_data(tvb, decrypted_data, size, reported_len); tvb_set_free_cb(decrypted_tvb, g_free); - tvb_set_child_real_data_tvbuff(tvb, decrypted_tvb); add_new_data_source(pinfo, decrypted_tvb, "Decrypted MAPI"); it = proto_tree_add_text(tree, decrypted_tvb, 0, size, "Decrypted MAPI PDU"); diff --git a/epan/dissectors/pidl/mapi/response.cnf.c b/epan/dissectors/pidl/mapi/response.cnf.c index 8b98669a2f..4f36592644 100644 --- a/epan/dissectors/pidl/mapi/response.cnf.c +++ b/epan/dissectors/pidl/mapi/response.cnf.c @@ -146,10 +146,8 @@ mapi_dissect_element_EcDoRpc_response_(tvbuff_t *tvb _U_, int offset _U_, packet decrypted_data[i] = ptr[i] ^ 0xA5; } - decrypted_tvb = tvb_new_real_data(decrypted_data, size, reported_len); + decrypted_tvb = tvb_new_child_real_data(tvb, decrypted_data, size, reported_len); tvb_set_free_cb(decrypted_tvb, g_free); - - tvb_set_child_real_data_tvbuff(tvb, decrypted_tvb); add_new_data_source(pinfo, decrypted_tvb, "Decrypted MAPI"); it = proto_tree_add_text(tree, decrypted_tvb, 0, size, "Decrypted MAPI PDU"); |