Skip to content

Commit

Permalink
Do not use ephemeral memory when adding a new data source
Browse files Browse the repository at this point in the history
svn path=/trunk/; revision=51424
  • Loading branch information
pquantin committed Aug 19, 2013
1 parent 81b6d6a commit 02cae55
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions asn1/snmp/packet-snmp-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion epan/dissectors/packet-lapsat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions epan/dissectors/packet-snmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 }},
Expand Down

0 comments on commit 02cae55

Please sign in to comment.