Do not use ephemeral memory when adding a new data source

svn path=/trunk/; revision=51424
This commit is contained in:
Pascal Quantin 2013-08-19 11:11:11 +00:00
parent 81b6d6aab3
commit 02cae558f9
3 changed files with 10 additions and 6 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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 }},