From 02cae558f997dba1fd17011cc84e317f17d17a4d Mon Sep 17 00:00:00 2001 From: Pascal Quantin Date: Mon, 19 Aug 2013 11:11:11 +0000 Subject: [PATCH] Do not use ephemeral memory when adding a new data source svn path=/trunk/; revision=51424 --- asn1/snmp/packet-snmp-template.c | 8 ++++++-- epan/dissectors/packet-lapsat.c | 2 +- epan/dissectors/packet-snmp.c | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/asn1/snmp/packet-snmp-template.c b/asn1/snmp/packet-snmp-template.c index db18fb28b6..ba96d57c6a 100644 --- a/asn1/snmp/packet-snmp-template.c +++ b/asn1/snmp/packet-snmp-template.c @@ -1594,7 +1594,7 @@ snmp_usm_priv_des(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gchar c cryptgrm = (guint8*)ep_tvb_memdup(encryptedData,0,-1); - cleartext = (guint8*)ep_alloc(cryptgrm_len); + cleartext = (guint8*)g_malloc(cryptgrm_len); err = gcry_cipher_open(&hd, GCRY_CIPHER_DES, GCRY_CIPHER_MODE_CBC, 0); if (err != GPG_ERR_NO_ERROR) goto on_gcry_error; @@ -1611,10 +1611,12 @@ snmp_usm_priv_des(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gchar c gcry_cipher_close(hd); clear_tvb = tvb_new_child_real_data(encryptedData, cleartext, cryptgrm_len, cryptgrm_len); + tvb_set_free_cb(clear_tvb, g_free); return clear_tvb; on_gcry_error: + g_free(cleartext); *error = (const gchar *)gpg_strerror(err); if (hd) gcry_cipher_close(hd); return NULL; @@ -1664,7 +1666,7 @@ snmp_usm_priv_aes_common(snmp_usm_params_t* p, tvbuff_t* encryptedData, gchar co } cryptgrm = (guint8*)ep_tvb_memdup(encryptedData,0,-1); - cleartext = (guint8*)ep_alloc(cryptgrm_len); + cleartext = (guint8*)g_malloc(cryptgrm_len); err = gcry_cipher_open(&hd, algo, GCRY_CIPHER_MODE_CFB, 0); if (err != GPG_ERR_NO_ERROR) goto on_gcry_error; @@ -1681,10 +1683,12 @@ snmp_usm_priv_aes_common(snmp_usm_params_t* p, tvbuff_t* encryptedData, gchar co gcry_cipher_close(hd); clear_tvb = tvb_new_child_real_data(encryptedData, cleartext, cryptgrm_len, cryptgrm_len); + tvb_set_free_cb(clear_tvb, g_free); return clear_tvb; on_gcry_error: + g_free(cleartext); *error = (const gchar *)gpg_strerror(err); if (hd) gcry_cipher_close(hd); return NULL; diff --git a/epan/dissectors/packet-lapsat.c b/epan/dissectors/packet-lapsat.c index 9c07c15a39..d0f9252c8b 100644 --- a/epan/dissectors/packet-lapsat.c +++ b/epan/dissectors/packet-lapsat.c @@ -507,7 +507,7 @@ dissect_lapsat(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint8 *data = (guint8 *)tvb_memdup(tvb, hlen, plen); data[plen-1] |= tvb_get_guint8(tvb, 2) << 4; payload = tvb_new_child_real_data(tvb, data, plen, plen); - tvb_set_free_cb(payload, g_free); + tvb_set_free_cb(payload, g_free); } else { /* Last nibble doesn't need merging */ payload = tvb_new_subset(tvb, hlen, plen, -1); diff --git a/epan/dissectors/packet-snmp.c b/epan/dissectors/packet-snmp.c index 10d8c05b9f..ae7c5c7cea 100644 --- a/epan/dissectors/packet-snmp.c +++ b/epan/dissectors/packet-snmp.c @@ -2980,7 +2980,7 @@ static void dissect_SMUX_PDUs_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, pro /*--- End of included file: packet-snmp-fn.c ---*/ -#line 1765 "../../asn1/snmp/packet-snmp-template.c" +#line 1769 "../../asn1/snmp/packet-snmp-template.c" guint @@ -3906,7 +3906,7 @@ void proto_register_snmp(void) { NULL, HFILL }}, /*--- End of included file: packet-snmp-hfarr.c ---*/ -#line 2426 "../../asn1/snmp/packet-snmp-template.c" +#line 2430 "../../asn1/snmp/packet-snmp-template.c" }; /* List of subtrees */ @@ -3946,7 +3946,7 @@ void proto_register_snmp(void) { &ett_snmp_RReqPDU_U, /*--- End of included file: packet-snmp-ettarr.c ---*/ -#line 2442 "../../asn1/snmp/packet-snmp-template.c" +#line 2446 "../../asn1/snmp/packet-snmp-template.c" }; static ei_register_info ei[] = { { &ei_snmp_failed_decrypted_data_pdu, { "snmp.failed_decrypted_data_pdu", PI_MALFORMED, PI_WARN, "Failed to decrypt encryptedPDU", EXPFILL }},