Convert more glib memory to wmem pinfo pool

Change-Id: I4cc23bc19a6bd8c6a8e0389eaf939dbb60fe0ca3
Reviewed-on: https://code.wireshark.org/review/16562
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Pascal Quantin 2016-07-20 23:54:35 +02:00 committed by Anders Broman
parent b2e4a7e21c
commit 53de2c2378
27 changed files with 86 additions and 154 deletions

View File

@ -194,7 +194,7 @@ RevocationInfoChoice/other otherRIC
item = actx->created_item;
PBE_decrypt_data(object_identifier_id, encrypted_tvb, actx, item);
PBE_decrypt_data(object_identifier_id, encrypted_tvb, actx->pinfo, actx, item);
#.END

View File

@ -388,7 +388,7 @@ decrypt_krb5_data(proto_tree *tree _U_, packet_info *pinfo,
}
read_keytab_file_from_preferences();
data.data = (char *)g_malloc(length);
data.data = (char *)wmem_alloc(pinfo->pool, length);
data.length = length;
for(ek=enc_key_list;ek;ek=ek->next){
@ -414,7 +414,6 @@ decrypt_krb5_data(proto_tree *tree _U_, packet_info *pinfo,
"Decrypted keytype %d in frame %u using %s",
ek->keytype, pinfo->num, ek->key_origin);
/* return a private g_malloced blob to the caller */
user_data=data.data;
if (datalen) {
*datalen = data.length;
@ -422,7 +421,6 @@ decrypt_krb5_data(proto_tree *tree _U_, packet_info *pinfo,
return user_data;
}
}
g_free(data.data);
return NULL;
}
@ -553,12 +551,11 @@ decrypt_krb5_data(proto_tree *tree _U_, packet_info *pinfo,
keys. So just give it a copy of the crypto data instead.
This has been seen for RC4-HMAC blobs.
*/
cryptocopy = (guint8 *)g_memdup(cryptotext, length);
cryptocopy = (guint8 *)wmem_memdup(wmem_packet_scope(), cryptotext, length);
ret = krb5_decrypt_ivec(krb5_ctx, crypto, usage,
cryptocopy, length,
&data,
NULL);
g_free(cryptocopy);
if((ret == 0) && (length>0)){
char *user_data;
@ -567,8 +564,8 @@ decrypt_krb5_data(proto_tree *tree _U_, packet_info *pinfo,
ek->keytype, pinfo->num, ek->key_origin);
krb5_crypto_destroy(krb5_ctx, crypto);
/* return a private g_malloced blob to the caller */
user_data = (char *)g_memdup(data.data, (guint)data.length);
/* return a private wmem_alloced blob to the caller */
user_data = (char *)wmem_memdup(pinfo->pool, data.data, (guint)data.length);
if (datalen) {
*datalen = (int)data.length;
}
@ -719,7 +716,7 @@ decrypt_krb5_data(proto_tree *tree, packet_info *pinfo,
return NULL;
}
decrypted_data = g_malloc(length);
decrypted_data = wmem_alloc(wmem_packet_scope(), length);
for(ske = service_key_list; ske != NULL; ske = g_slist_next(ske)){
gboolean do_continue = FALSE;
sk = (service_key_t *) ske->data;
@ -764,20 +761,17 @@ decrypt_krb5_data(proto_tree *tree, packet_info *pinfo,
md5_finish(&md5s, digest);
if (tvb_memeql (encr_tvb, 8, digest, 16) == 0) {
plaintext = g_malloc(data_len);
tvb_memcpy(encr_tvb, plaintext, CONFOUNDER_PLUS_CHECKSUM, data_len);
plaintext = (guint8* )tvb_memdup(pinfo->pool, encr_tvb, CONFOUNDER_PLUS_CHECKSUM, data_len);
tvb_free(encr_tvb);
if (datalen) {
*datalen = data_len;
}
g_free(decrypted_data);
return(plaintext);
}
tvb_free(encr_tvb);
}
g_free(decrypted_data);
return NULL;
}
@ -1348,7 +1342,6 @@ dissect_krb5_decrypt_ticket_data (gboolean imp_tag _U_, tvbuff_t *tvb, int offse
if(plaintext){
tvbuff_t *child_tvb;
child_tvb = tvb_new_child_real_data(tvb, plaintext, length, length);
tvb_set_free_cb(child_tvb, g_free);
/* Add the decrypted data to the data source list. */
add_new_data_source(actx->pinfo, child_tvb, "Decrypted Krb5");
@ -1385,7 +1378,6 @@ dissect_krb5_decrypt_authenticator_data (gboolean imp_tag _U_, tvbuff_t *tvb, in
if(plaintext){
tvbuff_t *child_tvb;
child_tvb = tvb_new_child_real_data(tvb, plaintext, length, length);
tvb_set_free_cb(child_tvb, g_free);
/* Add the decrypted data to the data source list. */
add_new_data_source(actx->pinfo, child_tvb, "Decrypted Krb5");
@ -1427,7 +1419,6 @@ dissect_krb5_decrypt_KDC_REP_data (gboolean imp_tag _U_, tvbuff_t *tvb, int offs
if(plaintext){
tvbuff_t *child_tvb;
child_tvb = tvb_new_child_real_data(tvb, plaintext, length, length);
tvb_set_free_cb(child_tvb, g_free);
/* Add the decrypted data to the data source list. */
add_new_data_source(actx->pinfo, child_tvb, "Decrypted Krb5");
@ -1459,7 +1450,6 @@ dissect_krb5_decrypt_PA_ENC_TIMESTAMP (gboolean imp_tag _U_, tvbuff_t *tvb, int
if(plaintext){
tvbuff_t *child_tvb;
child_tvb = tvb_new_child_real_data(tvb, plaintext, length, length);
tvb_set_free_cb(child_tvb, g_free);
/* Add the decrypted data to the data source list. */
add_new_data_source(actx->pinfo, child_tvb, "Decrypted Krb5");
@ -1490,7 +1480,6 @@ dissect_krb5_decrypt_AP_REP_data (gboolean imp_tag _U_, tvbuff_t *tvb, int offse
if(plaintext){
tvbuff_t *child_tvb;
child_tvb = tvb_new_child_real_data(tvb, plaintext, length, length);
tvb_set_free_cb(child_tvb, g_free);
/* Add the decrypted data to the data source list. */
add_new_data_source(actx->pinfo, child_tvb, "Decrypted Krb5");
@ -1521,7 +1510,6 @@ dissect_krb5_decrypt_PRIV_data (gboolean imp_tag _U_, tvbuff_t *tvb, int offset,
if(plaintext){
tvbuff_t *child_tvb;
child_tvb = tvb_new_child_real_data(tvb, plaintext, length, length);
tvb_set_free_cb(child_tvb, g_free);
/* Add the decrypted data to the data source list. */
add_new_data_source(actx->pinfo, child_tvb, "Decrypted Krb5");
@ -1552,7 +1540,6 @@ dissect_krb5_decrypt_CRED_data (gboolean imp_tag _U_, tvbuff_t *tvb, int offset,
if(plaintext){
tvbuff_t *child_tvb;
child_tvb = tvb_new_child_real_data(tvb, plaintext, length, length);
tvb_set_free_cb(child_tvb, g_free);
/* Add the decrypted data to the data source list. */
add_new_data_source(actx->pinfo, child_tvb, "Decrypted Krb5");

View File

@ -217,7 +217,7 @@ void PBE_reset_parameters(void)
salt = NULL;
}
int PBE_decrypt_data(const char *object_identifier_id_param _U_, tvbuff_t *encrypted_tvb _U_, asn1_ctx_t *actx _U_, proto_item *item _U_)
int PBE_decrypt_data(const char *object_identifier_id_param _U_, tvbuff_t *encrypted_tvb _U_, packet_info *pinfo _U_, asn1_ctx_t *actx _U_, proto_item *item _U_)
{
#ifdef HAVE_LIBGCRYPT
const char *encryption_algorithm;
@ -307,7 +307,7 @@ int PBE_decrypt_data(const char *object_identifier_id_param _U_, tvbuff_t *encry
}
datalen = tvb_captured_length(encrypted_tvb);
clear_data = (char *)g_malloc(datalen);
clear_data = (char *)wmem_alloc(pinfo->pool, datalen);
err = gcry_cipher_decrypt (cipher, clear_data, datalen, (char *)tvb_memdup(wmem_packet_scope(), encrypted_tvb, 0, datalen), datalen);
if (gcry_err_code (err)) {
@ -315,7 +315,6 @@ int PBE_decrypt_data(const char *object_identifier_id_param _U_, tvbuff_t *encry
proto_item_append_text(item, " [Failed to decrypt with password preference]");
gcry_cipher_close (cipher);
g_free(clear_data);
return FALSE;
}
@ -348,7 +347,6 @@ int PBE_decrypt_data(const char *object_identifier_id_param _U_, tvbuff_t *encry
}
if(!decrypt_ok) {
g_free(clear_data);
proto_item_append_text(item, " [Failed to decrypt with supplied password]");
return FALSE;
@ -361,7 +359,6 @@ int PBE_decrypt_data(const char *object_identifier_id_param _U_, tvbuff_t *encry
/* OK - so now clear_data contains the decrypted data */
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("");
oidname = oid_resolved_from_string(wmem_packet_scope(), object_identifier_id_param);

View File

@ -25,7 +25,7 @@
#define PACKET_PKCS12_H
void PBE_reset_parameters(void);
int PBE_decrypt_data(const char *object_identifier_id, tvbuff_t *encrypted_tvb, asn1_ctx_t *actx, proto_item *item);
int PBE_decrypt_data(const char *object_identifier_id, tvbuff_t *encrypted_tvb, packet_info *pinfo, asn1_ctx_t *actx, proto_item *item);
#endif /* PACKET_PKCS12_H */

View File

@ -148,7 +148,7 @@ PrivateKeyInfo
dissector_handle=create_dissector_handle(dissect_PrivateKeyInfo_PDU, proto_pkcs12);
dissector_change_string("ber.oid", object_identifier_id, dissector_handle);
PBE_decrypt_data(object_identifier_id, encrypted_tvb, actx, actx->created_item);
PBE_decrypt_data(object_identifier_id, encrypted_tvb, actx->pinfo, actx, actx->created_item);
/* restore the original dissector */
dissector_reset_string("ber.oid", object_identifier_id);

View File

@ -101,10 +101,10 @@ void proto_reg_handoff_smux(void);
static gboolean snmp_usm_auth_md5(snmp_usm_params_t* p, guint8**, guint*, gchar const**);
static gboolean snmp_usm_auth_sha1(snmp_usm_params_t* p, guint8**, guint*, gchar const**);
static tvbuff_t* snmp_usm_priv_des(snmp_usm_params_t*, tvbuff_t*, gchar const**);
static tvbuff_t* snmp_usm_priv_aes128(snmp_usm_params_t*, tvbuff_t*, gchar const**);
static tvbuff_t* snmp_usm_priv_aes192(snmp_usm_params_t*, tvbuff_t*, gchar const**);
static tvbuff_t* snmp_usm_priv_aes256(snmp_usm_params_t*, tvbuff_t*, gchar const**);
static tvbuff_t* snmp_usm_priv_des(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, gchar const**);
static tvbuff_t* snmp_usm_priv_aes128(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, gchar const**);
static tvbuff_t* snmp_usm_priv_aes192(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, gchar const**);
static tvbuff_t* snmp_usm_priv_aes256(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, gchar const**);
static void snmp_usm_password_to_key_md5(const guint8 *password, guint passwordlen, const guint8 *engineID, guint engineLength, guint8 *key);
@ -1655,7 +1655,7 @@ snmp_usm_auth_sha1(snmp_usm_params_t* p _U_, guint8** calc_auth_p, guint* calc_a
}
static tvbuff_t*
snmp_usm_priv_des(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gchar const** error _U_)
snmp_usm_priv_des(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, packet_info *pinfo _U_, gchar const** error _U_)
{
#ifdef HAVE_LIBGCRYPT
gcry_error_t err;
@ -1698,7 +1698,7 @@ snmp_usm_priv_des(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gchar c
cryptgrm = (guint8*)tvb_memdup(wmem_packet_scope(),encryptedData,0,-1);
cleartext = (guint8*)g_malloc(cryptgrm_len);
cleartext = (guint8*)wmem_alloc(pinfo->pool, 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;
@ -1715,12 +1715,10 @@ 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;
@ -1732,7 +1730,7 @@ on_gcry_error:
#ifdef HAVE_LIBGCRYPT
static tvbuff_t*
snmp_usm_priv_aes_common(snmp_usm_params_t* p, tvbuff_t* encryptedData, gchar const** error, int algo)
snmp_usm_priv_aes_common(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, gchar const** error, int algo)
{
gcry_error_t err;
gcry_cipher_hd_t hd = NULL;
@ -1770,7 +1768,7 @@ snmp_usm_priv_aes_common(snmp_usm_params_t* p, tvbuff_t* encryptedData, gchar co
}
cryptgrm = (guint8*)tvb_memdup(wmem_packet_scope(),encryptedData,0,-1);
cleartext = (guint8*)g_malloc(cryptgrm_len);
cleartext = (guint8*)wmem_alloc(pinfo->pool, cryptgrm_len);
err = gcry_cipher_open(&hd, algo, GCRY_CIPHER_MODE_CFB, 0);
if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;
@ -1787,12 +1785,10 @@ 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;
@ -1800,10 +1796,10 @@ on_gcry_error:
#endif
static tvbuff_t*
snmp_usm_priv_aes128(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gchar const** error)
snmp_usm_priv_aes128(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, packet_info *pinfo _U_, gchar const** error)
{
#ifdef HAVE_LIBGCRYPT
return snmp_usm_priv_aes_common(p, encryptedData, error, GCRY_CIPHER_AES);
return snmp_usm_priv_aes_common(p, encryptedData, pinfo, error, GCRY_CIPHER_AES);
#else
*error = "libgcrypt not present, cannot decrypt";
return NULL;
@ -1811,10 +1807,10 @@ snmp_usm_priv_aes128(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gcha
}
static tvbuff_t*
snmp_usm_priv_aes192(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gchar const** error)
snmp_usm_priv_aes192(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, packet_info *pinfo _U_, gchar const** error)
{
#ifdef HAVE_LIBGCRYPT
return snmp_usm_priv_aes_common(p, encryptedData, error, GCRY_CIPHER_AES192);
return snmp_usm_priv_aes_common(p, encryptedData, pinfo, error, GCRY_CIPHER_AES192);
#else
*error = "libgcrypt not present, cannot decrypt";
return NULL;
@ -1822,10 +1818,10 @@ snmp_usm_priv_aes192(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gcha
}
static tvbuff_t*
snmp_usm_priv_aes256(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gchar const** error)
snmp_usm_priv_aes256(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, packet_info *pinfo _U_, gchar const** error)
{
#ifdef HAVE_LIBGCRYPT
return snmp_usm_priv_aes_common(p, encryptedData, error, GCRY_CIPHER_AES256);
return snmp_usm_priv_aes_common(p, encryptedData, pinfo, error, GCRY_CIPHER_AES256);
#else
*error = "libgcrypt not present, cannot decrypt";
return NULL;

View File

@ -32,7 +32,7 @@ typedef struct _snmp_ue_assoc_t snmp_ue_assoc_t;
typedef struct _snmp_usm_params_t snmp_usm_params_t;
typedef gboolean (*snmp_usm_authenticator_t)(snmp_usm_params_t*, guint8** calc_auth, guint* calc_auth_len, gchar const** error);
typedef tvbuff_t* (*snmp_usm_decoder_t)(snmp_usm_params_t*, tvbuff_t* encryptedData, gchar const** error);
typedef tvbuff_t* (*snmp_usm_decoder_t)(snmp_usm_params_t*, tvbuff_t* encryptedData, packet_info *pinfo, gchar const** error);
typedef void (*snmp_usm_password_to_key_t)(const guint8 *password, guint passwordlen, const guint8 *engineID, guint engineLength, guint8 *key);
typedef struct _snmp_usm_auth_model_t {

View File

@ -129,7 +129,7 @@ gint pdu_type=-1;
const gchar* error = NULL;
proto_tree* encryptedpdu_tree = proto_item_add_subtree(%(ACTX)s->created_item,ett_encryptedPDU);
tvbuff_t* cleartext_tvb = usm_p.user_assoc->user.privProtocol(&usm_p, crypt_tvb, &error );
tvbuff_t* cleartext_tvb = usm_p.user_assoc->user.privProtocol(&usm_p, crypt_tvb, actx->pinfo, &error );
if (! cleartext_tvb) {
proto_tree_add_expert_format(encryptedpdu_tree, actx->pinfo, &ei_snmp_failed_decrypted_data_pdu,

View File

@ -716,15 +716,13 @@ decrypt_gssapi_krb_cfx_wrap(proto_tree *tree,
if (output) {
guint8 *outdata;
outdata = (guint8 *)g_memdup(output, tvb_captured_length(gssapi_encrypt->gssapi_encrypted_tvb));
g_free(output);
outdata = (guint8 *)wmem_memdup(pinfo->pool, output, tvb_captured_length(gssapi_encrypt->gssapi_encrypted_tvb));
gssapi_encrypt->gssapi_decrypted_tvb=tvb_new_child_real_data(gssapi_encrypt->gssapi_encrypted_tvb,
outdata,
tvb_captured_length(gssapi_encrypt->gssapi_encrypted_tvb),
tvb_captured_length(gssapi_encrypt->gssapi_encrypted_tvb));
add_new_data_source(pinfo, gssapi_encrypt->gssapi_decrypted_tvb, "Decrypted GSS-Krb5");
tvb_set_free_cb(gssapi_encrypt->gssapi_decrypted_tvb, g_free);
}
}

View File

@ -1353,7 +1353,7 @@ dissect_cms_EncryptedContent(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int o
item = actx->created_item;
PBE_decrypt_data(object_identifier_id, encrypted_tvb, actx, item);
PBE_decrypt_data(object_identifier_id, encrypted_tvb, actx->pinfo, actx, item);
return offset;

View File

@ -4034,7 +4034,7 @@ mapi_dissect_element_EcDoRpc_request(tvbuff_t *tvb _U_, int offset _U_, packet_i
return offset;
}
static int
mapi_dissect_element_EcDoRpc_request_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
mapi_dissect_element_EcDoRpc_request_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
{
guint32 size;
int start_offset = offset;
@ -4055,12 +4055,11 @@ mapi_dissect_element_EcDoRpc_request_(tvbuff_t *tvb _U_, int offset _U_, packet_
size = reported_len;
}
ptr = tvb_get_ptr(tvb, offset, size);
decrypted_data = (guint8 *)g_malloc(size);
decrypted_data = (guint8 *)wmem_alloc(pinfo->pool, size);
for (i = 0; i < size; i++) {
decrypted_data[i] = ptr[i] ^ 0xA5;
}
decrypted_tvb = tvb_new_child_real_data(tvb, decrypted_data, size, reported_len);
tvb_set_free_cb(decrypted_tvb, g_free);
add_new_data_source(pinfo, decrypted_tvb, "Decrypted MAPI");
tr = proto_tree_add_subtree(tree, decrypted_tvb, 0, size, ett_mapi_mapi_request, NULL, "Decrypted MAPI PDU");
pdu_len = tvb_get_letohs(decrypted_tvb, 0);
@ -4236,7 +4235,7 @@ mapi_dissect_element_EcDoRpc_response(tvbuff_t *tvb _U_, int offset _U_, packet_
return offset;
}
static int
mapi_dissect_element_EcDoRpc_response_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
mapi_dissect_element_EcDoRpc_response_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
{
guint32 size;
int start_offset = offset;
@ -4257,12 +4256,11 @@ mapi_dissect_element_EcDoRpc_response_(tvbuff_t *tvb _U_, int offset _U_, packet
size = reported_len;
}
ptr = tvb_get_ptr(tvb, offset, size);
decrypted_data = (guint8 *)g_malloc(size);
decrypted_data = (guint8 *)wmem_alloc(pinfo->pool, size);
for (i = 0; i < size; i++) {
decrypted_data[i] = ptr[i] ^ 0xA5;
}
decrypted_tvb = tvb_new_child_real_data(tvb, decrypted_data, size, reported_len);
tvb_set_free_cb(decrypted_tvb, g_free);
add_new_data_source(pinfo, decrypted_tvb, "Decrypted MAPI");
tr = proto_tree_add_subtree(tree, decrypted_tvb, 0, size, ett_mapi_mapi_response, NULL, "Decrypted MAPI PDU");
pdu_len = tvb_get_letohs(decrypted_tvb, 0);

View File

@ -1839,7 +1839,7 @@ chunked_encoding_dissector(tvbuff_t **tvb_ptr, packet_info *pinfo,
chunked_data_size += chunk_size;
raw_data = g_malloc(chunked_data_size);
raw_data = wmem_alloc(pinfo->pool, chunked_data_size);
raw_len = 0;
if (new_tvb != NULL) {
@ -1857,7 +1857,6 @@ chunked_encoding_dissector(tvbuff_t **tvb_ptr, packet_info *pinfo,
if(chunked_data_size > 0) {
new_tvb = tvb_new_real_data(raw_data,
chunked_data_size, chunked_data_size);
tvb_set_free_cb(new_tvb, g_free);
}

View File

@ -224,7 +224,7 @@ static void
ieee_80211_add_tagged_parameters(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_tree *tree, int tagged_parameters_len, int ftype);
static tvbuff_t *try_decrypt(tvbuff_t *tvb, guint32 offset, guint32 len, guint8 *algorithm, guint32 *sec_header, guint32 *sec_trailer, PAIRPDCAP_KEY_ITEM used_key);
static tvbuff_t *try_decrypt(tvbuff_t *tvb, packet_info *pinfo, guint32 offset, guint32 len, guint8 *algorithm, guint32 *sec_header, guint32 *sec_trailer, PAIRPDCAP_KEY_ITEM used_key);
static int weak_iv(guchar *iv);
@ -17785,7 +17785,7 @@ dissect_ieee80211_common(tvbuff_t *tvb, packet_info *pinfo,
guint32 sec_header=0;
guint32 sec_trailer=0;
next_tvb = try_decrypt(tvb, hdr_len, reported_len, &algorithm, &sec_header, &sec_trailer, &used_key);
next_tvb = try_decrypt(tvb, pinfo, hdr_len, reported_len, &algorithm, &sec_header, &sec_trailer, &used_key);
keybyte = tvb_get_guint8(tvb, hdr_len + 3);
key = KEY_OCTET_WEP_KEY(keybyte);
@ -18624,7 +18624,7 @@ dissect_wlan_rsna_eapol_wpa_or_rsn_key(tvbuff_t *tvb, packet_info *pinfo, proto_
/* It returns the algorithm used for decryption and the header and trailer lengths. */
static tvbuff_t *
try_decrypt(tvbuff_t *tvb, guint offset, guint len, guint8 *algorithm, guint32 *sec_header, guint32 *sec_trailer, PAIRPDCAP_KEY_ITEM used_key)
try_decrypt(tvbuff_t *tvb, packet_info *pinfo, guint offset, guint len, guint8 *algorithm, guint32 *sec_header, guint32 *sec_trailer, PAIRPDCAP_KEY_ITEM used_key)
{
const guint8 *enc_data;
tvbuff_t *decr_tvb = NULL;
@ -18661,13 +18661,12 @@ try_decrypt(tvbuff_t *tvb, guint offset, guint len, guint8 *algorithm, guint32 *
}
/* allocate buffer for decrypted payload */
tmp = (guint8 *)g_memdup(dec_data+offset, dec_caplen-offset);
tmp = (guint8 *)wmem_memdup(pinfo->pool, dec_data+offset, dec_caplen-offset);
len = dec_caplen-offset;
/* decrypt successful, let's set up a new data tvb. */
decr_tvb = tvb_new_child_real_data(tvb, tmp, len, len);
tvb_set_free_cb(decr_tvb, g_free);
}
return decr_tvb;

View File

@ -1973,15 +1973,12 @@ dissect_esp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
if(decrypt_ok && (decrypted_len > esp_iv_len))
{
tvb_decrypted = tvb_new_child_real_data(tvb, (guint8 *)g_memdup(decrypted_data+sizeof(guint8)*esp_iv_len,
tvb_decrypted = tvb_new_child_real_data(tvb, (guint8 *)wmem_memdup(pinfo->pool, decrypted_data+sizeof(guint8)*esp_iv_len,
decrypted_len - esp_iv_len),
decrypted_len - esp_iv_len, decrypted_len - esp_iv_len);
add_new_data_source(pinfo, tvb_decrypted, "Decrypted Data");
/* Handler to free the Decrypted Data Buffer. */
tvb_set_free_cb(tvb_decrypted,g_free);
if(tvb_bytes_exist(tvb, 8, esp_iv_len))
{
if(esp_iv_len > 0)

View File

@ -647,7 +647,7 @@ decrypt_krb5_data(proto_tree *tree _U_, packet_info *pinfo,
}
read_keytab_file_from_preferences();
data.data = (char *)g_malloc(length);
data.data = (char *)wmem_alloc(pinfo->pool, length);
data.length = length;
for(ek=enc_key_list;ek;ek=ek->next){
@ -673,7 +673,6 @@ decrypt_krb5_data(proto_tree *tree _U_, packet_info *pinfo,
"Decrypted keytype %d in frame %u using %s",
ek->keytype, pinfo->num, ek->key_origin);
/* return a private g_malloced blob to the caller */
user_data=data.data;
if (datalen) {
*datalen = data.length;
@ -681,7 +680,6 @@ decrypt_krb5_data(proto_tree *tree _U_, packet_info *pinfo,
return user_data;
}
}
g_free(data.data);
return NULL;
}
@ -812,12 +810,11 @@ decrypt_krb5_data(proto_tree *tree _U_, packet_info *pinfo,
keys. So just give it a copy of the crypto data instead.
This has been seen for RC4-HMAC blobs.
*/
cryptocopy = (guint8 *)g_memdup(cryptotext, length);
cryptocopy = (guint8 *)wmem_memdup(wmem_packet_scope(), cryptotext, length);
ret = krb5_decrypt_ivec(krb5_ctx, crypto, usage,
cryptocopy, length,
&data,
NULL);
g_free(cryptocopy);
if((ret == 0) && (length>0)){
char *user_data;
@ -826,8 +823,8 @@ decrypt_krb5_data(proto_tree *tree _U_, packet_info *pinfo,
ek->keytype, pinfo->num, ek->key_origin);
krb5_crypto_destroy(krb5_ctx, crypto);
/* return a private g_malloced blob to the caller */
user_data = (char *)g_memdup(data.data, (guint)data.length);
/* return a private wmem_alloced blob to the caller */
user_data = (char *)wmem_memdup(pinfo->pool, data.data, (guint)data.length);
if (datalen) {
*datalen = (int)data.length;
}
@ -978,7 +975,7 @@ decrypt_krb5_data(proto_tree *tree, packet_info *pinfo,
return NULL;
}
decrypted_data = g_malloc(length);
decrypted_data = wmem_alloc(wmem_packet_scope(), length);
for(ske = service_key_list; ske != NULL; ske = g_slist_next(ske)){
gboolean do_continue = FALSE;
sk = (service_key_t *) ske->data;
@ -1023,20 +1020,17 @@ decrypt_krb5_data(proto_tree *tree, packet_info *pinfo,
md5_finish(&md5s, digest);
if (tvb_memeql (encr_tvb, 8, digest, 16) == 0) {
plaintext = g_malloc(data_len);
tvb_memcpy(encr_tvb, plaintext, CONFOUNDER_PLUS_CHECKSUM, data_len);
plaintext = (guint8* )tvb_memdup(pinfo->pool, encr_tvb, CONFOUNDER_PLUS_CHECKSUM, data_len);
tvb_free(encr_tvb);
if (datalen) {
*datalen = data_len;
}
g_free(decrypted_data);
return(plaintext);
}
tvb_free(encr_tvb);
}
g_free(decrypted_data);
return NULL;
}
@ -1607,7 +1601,6 @@ dissect_krb5_decrypt_ticket_data (gboolean imp_tag _U_, tvbuff_t *tvb, int offse
if(plaintext){
tvbuff_t *child_tvb;
child_tvb = tvb_new_child_real_data(tvb, plaintext, length, length);
tvb_set_free_cb(child_tvb, g_free);
/* Add the decrypted data to the data source list. */
add_new_data_source(actx->pinfo, child_tvb, "Decrypted Krb5");
@ -1644,7 +1637,6 @@ dissect_krb5_decrypt_authenticator_data (gboolean imp_tag _U_, tvbuff_t *tvb, in
if(plaintext){
tvbuff_t *child_tvb;
child_tvb = tvb_new_child_real_data(tvb, plaintext, length, length);
tvb_set_free_cb(child_tvb, g_free);
/* Add the decrypted data to the data source list. */
add_new_data_source(actx->pinfo, child_tvb, "Decrypted Krb5");
@ -1686,7 +1678,6 @@ dissect_krb5_decrypt_KDC_REP_data (gboolean imp_tag _U_, tvbuff_t *tvb, int offs
if(plaintext){
tvbuff_t *child_tvb;
child_tvb = tvb_new_child_real_data(tvb, plaintext, length, length);
tvb_set_free_cb(child_tvb, g_free);
/* Add the decrypted data to the data source list. */
add_new_data_source(actx->pinfo, child_tvb, "Decrypted Krb5");
@ -1718,7 +1709,6 @@ dissect_krb5_decrypt_PA_ENC_TIMESTAMP (gboolean imp_tag _U_, tvbuff_t *tvb, int
if(plaintext){
tvbuff_t *child_tvb;
child_tvb = tvb_new_child_real_data(tvb, plaintext, length, length);
tvb_set_free_cb(child_tvb, g_free);
/* Add the decrypted data to the data source list. */
add_new_data_source(actx->pinfo, child_tvb, "Decrypted Krb5");
@ -1749,7 +1739,6 @@ dissect_krb5_decrypt_AP_REP_data (gboolean imp_tag _U_, tvbuff_t *tvb, int offse
if(plaintext){
tvbuff_t *child_tvb;
child_tvb = tvb_new_child_real_data(tvb, plaintext, length, length);
tvb_set_free_cb(child_tvb, g_free);
/* Add the decrypted data to the data source list. */
add_new_data_source(actx->pinfo, child_tvb, "Decrypted Krb5");
@ -1780,7 +1769,6 @@ dissect_krb5_decrypt_PRIV_data (gboolean imp_tag _U_, tvbuff_t *tvb, int offset,
if(plaintext){
tvbuff_t *child_tvb;
child_tvb = tvb_new_child_real_data(tvb, plaintext, length, length);
tvb_set_free_cb(child_tvb, g_free);
/* Add the decrypted data to the data source list. */
add_new_data_source(actx->pinfo, child_tvb, "Decrypted Krb5");
@ -1811,7 +1799,6 @@ dissect_krb5_decrypt_CRED_data (gboolean imp_tag _U_, tvbuff_t *tvb, int offset,
if(plaintext){
tvbuff_t *child_tvb;
child_tvb = tvb_new_child_real_data(tvb, plaintext, length, length);
tvb_set_free_cb(child_tvb, g_free);
/* Add the decrypted data to the data source list. */
add_new_data_source(actx->pinfo, child_tvb, "Decrypted Krb5");
@ -4341,7 +4328,7 @@ dissect_kerberos_ChangePasswdData(gboolean implicit_tag _U_, tvbuff_t *tvb _U_,
/*--- End of included file: packet-kerberos-fn.c ---*/
#line 1985 "./asn1/kerberos/packet-kerberos-template.c"
#line 1972 "./asn1/kerberos/packet-kerberos-template.c"
/* Make wrappers around exported functions for now */
int
@ -5395,7 +5382,7 @@ void proto_register_kerberos(void) {
NULL, HFILL }},
/*--- End of included file: packet-kerberos-hfarr.c ---*/
#line 2366 "./asn1/kerberos/packet-kerberos-template.c"
#line 2353 "./asn1/kerberos/packet-kerberos-template.c"
};
/* List of subtrees */
@ -5473,7 +5460,7 @@ void proto_register_kerberos(void) {
&ett_kerberos_ChangePasswdData,
/*--- End of included file: packet-kerberos-ettarr.c ---*/
#line 2382 "./asn1/kerberos/packet-kerberos-template.c"
#line 2369 "./asn1/kerberos/packet-kerberos-template.c"
};
static ei_register_info ei[] = {

View File

@ -692,7 +692,6 @@ dissect_payload_kink_encrypt(packet_info *pinfo, tvbuff_t *tvb, int offset, prot
plaintext=decrypt_krb5_data(tree, pinfo, 0, next_tvb, keytype, NULL);
if(plaintext){
next_tvb=tvb_new_child_real_data(tvb, plaintext, encrypt_length, encrypt_length);
tvb_set_free_cb(next_tvb, g_free);
add_new_data_source(pinfo, next_tvb, "decrypted kink encrypt");
dissect_decrypt_kink_encrypt(pinfo, next_tvb, tree, encrypt_length);
}

View File

@ -298,10 +298,9 @@ dissect_lapd_bitstream(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void
if (ones == 5 && state == DATA) {
/* we don't increase bit_offset, it is an inserted zero */
} else if (ones == 6 && state == DATA) { /* probably starting flag sequence */
buff = (guint8 *)g_memdup(data, data_len);
buff = (guint8 *)wmem_memdup(pinfo->pool, data, data_len);
/* Allocate new tvb for the LAPD frame */
new_tvb = tvb_new_child_real_data(tvb, buff, data_len, data_len);
tvb_set_free_cb(new_tvb, g_free);
add_new_data_source(pinfo, new_tvb, "Decoded LAPD bitstream");
data_len = 0;
state = FLAGS;

View File

@ -308,7 +308,7 @@ void PBE_reset_parameters(void)
salt = NULL;
}
int PBE_decrypt_data(const char *object_identifier_id_param _U_, tvbuff_t *encrypted_tvb _U_, asn1_ctx_t *actx _U_, proto_item *item _U_)
int PBE_decrypt_data(const char *object_identifier_id_param _U_, tvbuff_t *encrypted_tvb _U_, packet_info *pinfo _U_, asn1_ctx_t *actx _U_, proto_item *item _U_)
{
#ifdef HAVE_LIBGCRYPT
const char *encryption_algorithm;
@ -398,7 +398,7 @@ int PBE_decrypt_data(const char *object_identifier_id_param _U_, tvbuff_t *encry
}
datalen = tvb_captured_length(encrypted_tvb);
clear_data = (char *)g_malloc(datalen);
clear_data = (char *)wmem_alloc(pinfo->pool, datalen);
err = gcry_cipher_decrypt (cipher, clear_data, datalen, (char *)tvb_memdup(wmem_packet_scope(), encrypted_tvb, 0, datalen), datalen);
if (gcry_err_code (err)) {
@ -406,7 +406,6 @@ int PBE_decrypt_data(const char *object_identifier_id_param _U_, tvbuff_t *encry
proto_item_append_text(item, " [Failed to decrypt with password preference]");
gcry_cipher_close (cipher);
g_free(clear_data);
return FALSE;
}
@ -439,7 +438,6 @@ int PBE_decrypt_data(const char *object_identifier_id_param _U_, tvbuff_t *encry
}
if(!decrypt_ok) {
g_free(clear_data);
proto_item_append_text(item, " [Failed to decrypt with supplied password]");
return FALSE;
@ -452,7 +450,6 @@ int PBE_decrypt_data(const char *object_identifier_id_param _U_, tvbuff_t *encry
/* OK - so now clear_data contains the decrypted data */
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("");
oidname = oid_resolved_from_string(wmem_packet_scope(), object_identifier_id_param);
@ -802,7 +799,7 @@ dissect_pkcs12_EncryptedData(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int o
dissector_handle=create_dissector_handle(dissect_PrivateKeyInfo_PDU, proto_pkcs12);
dissector_change_string("ber.oid", object_identifier_id, dissector_handle);
PBE_decrypt_data(object_identifier_id, encrypted_tvb, actx, actx->created_item);
PBE_decrypt_data(object_identifier_id, encrypted_tvb, actx->pinfo, actx, actx->created_item);
/* restore the original dissector */
dissector_reset_string("ber.oid", object_identifier_id);
@ -1150,7 +1147,7 @@ static int dissect_PBMAC1Params_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, p
/*--- End of included file: packet-pkcs12-fn.c ---*/
#line 387 "./asn1/pkcs12/packet-pkcs12-template.c"
#line 384 "./asn1/pkcs12/packet-pkcs12-template.c"
static int strip_octet_string(tvbuff_t *tvb)
{
@ -1443,7 +1440,7 @@ void proto_register_pkcs12(void) {
"AlgorithmIdentifier", HFILL }},
/*--- End of included file: packet-pkcs12-hfarr.c ---*/
#line 463 "./asn1/pkcs12/packet-pkcs12-template.c"
#line 460 "./asn1/pkcs12/packet-pkcs12-template.c"
};
/* List of subtrees */
@ -1474,7 +1471,7 @@ void proto_register_pkcs12(void) {
&ett_pkcs12_PBMAC1Params,
/*--- End of included file: packet-pkcs12-ettarr.c ---*/
#line 469 "./asn1/pkcs12/packet-pkcs12-template.c"
#line 466 "./asn1/pkcs12/packet-pkcs12-template.c"
};
static ei_register_info ei[] = {
{ &ei_pkcs12_octet_string_expected, { "pkcs12.octet_string_expected", PI_PROTOCOL, PI_WARN, "BER Error: OCTET STRING expected", EXPFILL }},
@ -1542,7 +1539,7 @@ void proto_reg_handoff_pkcs12(void) {
/*--- End of included file: packet-pkcs12-dis-tab.c ---*/
#line 508 "./asn1/pkcs12/packet-pkcs12-template.c"
#line 505 "./asn1/pkcs12/packet-pkcs12-template.c"
register_ber_oid_dissector("1.2.840.113549.1.9.22.1", dissect_X509Certificate_OCTETSTRING_PDU, proto_pkcs12, "x509Certificate");

View File

@ -33,7 +33,7 @@
#define PACKET_PKCS12_H
void PBE_reset_parameters(void);
int PBE_decrypt_data(const char *object_identifier_id, tvbuff_t *encrypted_tvb, asn1_ctx_t *actx, proto_item *item);
int PBE_decrypt_data(const char *object_identifier_id, tvbuff_t *encrypted_tvb, packet_info *pinfo, asn1_ctx_t *actx, proto_item *item);
#endif /* PACKET_PKCS12_H */

View File

@ -1931,7 +1931,7 @@ decompress_sigcomp_message(tvbuff_t *bytecode_tvb, tvbuff_t *message_tvb, packet
"UDVM EXECUTION STARTED at Address: %u Message size %u", current_address, msg_end);
/* Largest allowed size for a message is UDVM_MEMORY_SIZE = 65536 */
out_buff = (guint8 *)g_malloc(UDVM_MEMORY_SIZE);
out_buff = (guint8 *)wmem_alloc(pinfo->pool, UDVM_MEMORY_SIZE);
/* Reset offset so proto_tree_add_xxx items below accurately reflect the bytes they represent */
offset = 0;
@ -1964,10 +1964,6 @@ execute_next_instruction:
if ( output_address > 0 ) {
/* At least something got decompressed, show it */
decomp_tvb = tvb_new_child_real_data(message_tvb, out_buff,output_address,output_address);
/* Arrange that the allocated packet data copy be freed when the
* tvbuff is freed.
*/
tvb_set_free_cb( decomp_tvb, g_free );
/* Add the tvbuff to the list of tvbuffs to which the tvbuff we
* were handed refers, so it'll get cleaned up when that tvbuff
* is cleaned up.
@ -1976,7 +1972,6 @@ execute_next_instruction:
proto_tree_add_expert(udvm_tree, pinfo, &ei_sigcomp_sigcomp_message_decompression_failure, decomp_tvb, 0, -1);
return decomp_tvb;
}
g_free(out_buff);
return NULL;
break;
@ -4401,10 +4396,6 @@ execute_next_instruction:
/* At least something got decompressed, show it */
decomp_tvb = tvb_new_child_real_data(message_tvb, out_buff,output_address,output_address);
/* Arrange that the allocated packet data copy be freed when the
* tvbuff is freed.
*/
tvb_set_free_cb( decomp_tvb, g_free );
add_new_data_source(pinfo, decomp_tvb, "Decompressed SigComp message");
proto_tree_add_item(udvm_tree, hf_sigcomp_sigcomp_message_decompressed, decomp_tvb, 0, -1, ENC_NA);
@ -4420,13 +4411,11 @@ execute_next_instruction:
"Addr %u Invalid instruction: %u (0x%x)", current_address,current_instruction,current_instruction);
break;
}
g_free(out_buff);
return NULL;
decompression_failure:
proto_tree_add_expert_format(udvm_tree, pinfo, &ei_sigcomp_decompression_failure, bytecode_tvb, 0, -1,
"DECOMPRESSION FAILURE: %s", val_to_str(result_code, result_code_vals,"Unknown (%u)"));
g_free(out_buff);
return NULL;
}

View File

@ -109,10 +109,10 @@ void proto_reg_handoff_smux(void);
static gboolean snmp_usm_auth_md5(snmp_usm_params_t* p, guint8**, guint*, gchar const**);
static gboolean snmp_usm_auth_sha1(snmp_usm_params_t* p, guint8**, guint*, gchar const**);
static tvbuff_t* snmp_usm_priv_des(snmp_usm_params_t*, tvbuff_t*, gchar const**);
static tvbuff_t* snmp_usm_priv_aes128(snmp_usm_params_t*, tvbuff_t*, gchar const**);
static tvbuff_t* snmp_usm_priv_aes192(snmp_usm_params_t*, tvbuff_t*, gchar const**);
static tvbuff_t* snmp_usm_priv_aes256(snmp_usm_params_t*, tvbuff_t*, gchar const**);
static tvbuff_t* snmp_usm_priv_des(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, gchar const**);
static tvbuff_t* snmp_usm_priv_aes128(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, gchar const**);
static tvbuff_t* snmp_usm_priv_aes192(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, gchar const**);
static tvbuff_t* snmp_usm_priv_aes256(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, gchar const**);
static void snmp_usm_password_to_key_md5(const guint8 *password, guint passwordlen, const guint8 *engineID, guint engineLength, guint8 *key);
@ -1757,7 +1757,7 @@ snmp_usm_auth_sha1(snmp_usm_params_t* p _U_, guint8** calc_auth_p, guint* calc_a
}
static tvbuff_t*
snmp_usm_priv_des(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gchar const** error _U_)
snmp_usm_priv_des(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, packet_info *pinfo _U_, gchar const** error _U_)
{
#ifdef HAVE_LIBGCRYPT
gcry_error_t err;
@ -1800,7 +1800,7 @@ snmp_usm_priv_des(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gchar c
cryptgrm = (guint8*)tvb_memdup(wmem_packet_scope(),encryptedData,0,-1);
cleartext = (guint8*)g_malloc(cryptgrm_len);
cleartext = (guint8*)wmem_alloc(pinfo->pool, 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;
@ -1817,12 +1817,10 @@ 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;
@ -1834,7 +1832,7 @@ on_gcry_error:
#ifdef HAVE_LIBGCRYPT
static tvbuff_t*
snmp_usm_priv_aes_common(snmp_usm_params_t* p, tvbuff_t* encryptedData, gchar const** error, int algo)
snmp_usm_priv_aes_common(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, gchar const** error, int algo)
{
gcry_error_t err;
gcry_cipher_hd_t hd = NULL;
@ -1872,7 +1870,7 @@ snmp_usm_priv_aes_common(snmp_usm_params_t* p, tvbuff_t* encryptedData, gchar co
}
cryptgrm = (guint8*)tvb_memdup(wmem_packet_scope(),encryptedData,0,-1);
cleartext = (guint8*)g_malloc(cryptgrm_len);
cleartext = (guint8*)wmem_alloc(pinfo->pool, cryptgrm_len);
err = gcry_cipher_open(&hd, algo, GCRY_CIPHER_MODE_CFB, 0);
if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;
@ -1889,12 +1887,10 @@ 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;
@ -1902,10 +1898,10 @@ on_gcry_error:
#endif
static tvbuff_t*
snmp_usm_priv_aes128(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gchar const** error)
snmp_usm_priv_aes128(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, packet_info *pinfo _U_, gchar const** error)
{
#ifdef HAVE_LIBGCRYPT
return snmp_usm_priv_aes_common(p, encryptedData, error, GCRY_CIPHER_AES);
return snmp_usm_priv_aes_common(p, encryptedData, pinfo, error, GCRY_CIPHER_AES);
#else
*error = "libgcrypt not present, cannot decrypt";
return NULL;
@ -1913,10 +1909,10 @@ snmp_usm_priv_aes128(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gcha
}
static tvbuff_t*
snmp_usm_priv_aes192(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gchar const** error)
snmp_usm_priv_aes192(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, packet_info *pinfo _U_, gchar const** error)
{
#ifdef HAVE_LIBGCRYPT
return snmp_usm_priv_aes_common(p, encryptedData, error, GCRY_CIPHER_AES192);
return snmp_usm_priv_aes_common(p, encryptedData, pinfo, error, GCRY_CIPHER_AES192);
#else
*error = "libgcrypt not present, cannot decrypt";
return NULL;
@ -1924,10 +1920,10 @@ snmp_usm_priv_aes192(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gcha
}
static tvbuff_t*
snmp_usm_priv_aes256(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gchar const** error)
snmp_usm_priv_aes256(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, packet_info *pinfo _U_, gchar const** error)
{
#ifdef HAVE_LIBGCRYPT
return snmp_usm_priv_aes_common(p, encryptedData, error, GCRY_CIPHER_AES256);
return snmp_usm_priv_aes_common(p, encryptedData, pinfo, error, GCRY_CIPHER_AES256);
#else
*error = "libgcrypt not present, cannot decrypt";
return NULL;
@ -2691,7 +2687,7 @@ dissect_snmp_T_encryptedPDU(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int of
const gchar* error = NULL;
proto_tree* encryptedpdu_tree = proto_item_add_subtree(actx->created_item,ett_encryptedPDU);
tvbuff_t* cleartext_tvb = usm_p.user_assoc->user.privProtocol(&usm_p, crypt_tvb, &error );
tvbuff_t* cleartext_tvb = usm_p.user_assoc->user.privProtocol(&usm_p, crypt_tvb, actx->pinfo, &error );
if (! cleartext_tvb) {
proto_tree_add_expert_format(encryptedpdu_tree, actx->pinfo, &ei_snmp_failed_decrypted_data_pdu,
@ -3078,7 +3074,7 @@ static int dissect_SMUX_PDUs_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, prot
/*--- End of included file: packet-snmp-fn.c ---*/
#line 1873 "./asn1/snmp/packet-snmp-template.c"
#line 1869 "./asn1/snmp/packet-snmp-template.c"
guint
@ -3895,7 +3891,7 @@ void proto_register_snmp(void) {
NULL, HFILL }},
/*--- End of included file: packet-snmp-hfarr.c ---*/
#line 2425 "./asn1/snmp/packet-snmp-template.c"
#line 2421 "./asn1/snmp/packet-snmp-template.c"
};
/* List of subtrees */
@ -3935,7 +3931,7 @@ void proto_register_snmp(void) {
&ett_snmp_RReqPDU_U,
/*--- End of included file: packet-snmp-ettarr.c ---*/
#line 2441 "./asn1/snmp/packet-snmp-template.c"
#line 2437 "./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 }},

View File

@ -40,7 +40,7 @@ typedef struct _snmp_ue_assoc_t snmp_ue_assoc_t;
typedef struct _snmp_usm_params_t snmp_usm_params_t;
typedef gboolean (*snmp_usm_authenticator_t)(snmp_usm_params_t*, guint8** calc_auth, guint* calc_auth_len, gchar const** error);
typedef tvbuff_t* (*snmp_usm_decoder_t)(snmp_usm_params_t*, tvbuff_t* encryptedData, gchar const** error);
typedef tvbuff_t* (*snmp_usm_decoder_t)(snmp_usm_params_t*, tvbuff_t* encryptedData, packet_info *pinfo, gchar const** error);
typedef void (*snmp_usm_password_to_key_t)(const guint8 *password, guint passwordlen, const guint8 *engineID, guint engineLength, guint8 *key);
typedef struct _snmp_usm_auth_model_t {

View File

@ -1168,15 +1168,13 @@ decrypt_gssapi_krb_cfx_wrap(proto_tree *tree,
if (output) {
guint8 *outdata;
outdata = (guint8 *)g_memdup(output, tvb_captured_length(gssapi_encrypt->gssapi_encrypted_tvb));
g_free(output);
outdata = (guint8 *)wmem_memdup(pinfo->pool, output, tvb_captured_length(gssapi_encrypt->gssapi_encrypted_tvb));
gssapi_encrypt->gssapi_decrypted_tvb=tvb_new_child_real_data(gssapi_encrypt->gssapi_encrypted_tvb,
outdata,
tvb_captured_length(gssapi_encrypt->gssapi_encrypted_tvb),
tvb_captured_length(gssapi_encrypt->gssapi_encrypted_tvb));
add_new_data_source(pinfo, gssapi_encrypt->gssapi_decrypted_tvb, "Decrypted GSS-Krb5");
tvb_set_free_cb(gssapi_encrypt->gssapi_decrypted_tvb, g_free);
}
}
@ -1966,7 +1964,7 @@ void proto_register_spnego(void) {
NULL, HFILL }},
/*--- End of included file: packet-spnego-hfarr.c ---*/
#line 1421 "./asn1/spnego/packet-spnego-template.c"
#line 1419 "./asn1/spnego/packet-spnego-template.c"
};
/* List of subtrees */
@ -1989,7 +1987,7 @@ void proto_register_spnego(void) {
&ett_spnego_InitialContextToken_U,
/*--- End of included file: packet-spnego-ettarr.c ---*/
#line 1431 "./asn1/spnego/packet-spnego-template.c"
#line 1429 "./asn1/spnego/packet-spnego-template.c"
};
static ei_register_info ei[] = {

View File

@ -191,10 +191,9 @@ static int dissect_tdmop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo
}
if (dchannel_len>0)
{
guint8 *buff = (guint8 *)g_memdup(dchannel_data, dchannel_len);
guint8 *buff = (guint8 *)wmem_memdup(pinfo->pool, dchannel_data, dchannel_len);
tvbuff_t *new_tvb;
new_tvb = tvb_new_child_real_data(tvb, buff, dchannel_len, dchannel_len);
tvb_set_free_cb(new_tvb, g_free);
call_dissector(lapd_handle, new_tvb, pinfo, tree);
}
}

View File

@ -111,7 +111,7 @@ mapi_dissect_element_EcDoRpc_request(tvbuff_t *tvb _U_, int offset _U_, packet_i
static int
mapi_dissect_element_EcDoRpc_request_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
mapi_dissect_element_EcDoRpc_request_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
{
guint32 size;
int start_offset = offset;
@ -137,13 +137,12 @@ mapi_dissect_element_EcDoRpc_request_(tvbuff_t *tvb _U_, int offset _U_, packet_
ptr = tvb_get_ptr(tvb, offset, size);
decrypted_data = (guint8 *)g_malloc(size);
decrypted_data = (guint8 *)wmem_alloc(pinfo->pool, size);
for (i = 0; i < size; i++) {
decrypted_data[i] = ptr[i] ^ 0xA5;
}
decrypted_tvb = tvb_new_child_real_data(tvb, decrypted_data, size, reported_len);
tvb_set_free_cb(decrypted_tvb, g_free);
add_new_data_source(pinfo, decrypted_tvb, "Decrypted MAPI");

View File

@ -115,7 +115,7 @@ mapi_dissect_element_EcDoRpc_response(tvbuff_t *tvb _U_, int offset _U_, packet_
static int
mapi_dissect_element_EcDoRpc_response_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
mapi_dissect_element_EcDoRpc_response_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
{
guint32 size;
int start_offset = offset;
@ -142,13 +142,12 @@ mapi_dissect_element_EcDoRpc_response_(tvbuff_t *tvb _U_, int offset _U_, packet
ptr = tvb_get_ptr(tvb, offset, size);
decrypted_data = (guint8 *)g_malloc(size);
decrypted_data = (guint8 *)wmem_alloc(pinfo->pool, size);
for (i = 0; i < size; i++) {
decrypted_data[i] = ptr[i] ^ 0xA5;
}
decrypted_tvb = tvb_new_child_real_data(tvb, decrypted_data, size, reported_len);
tvb_set_free_cb(decrypted_tvb, g_free);
add_new_data_source(pinfo, decrypted_tvb, "Decrypted MAPI");
tr = proto_tree_add_subtree(tree, decrypted_tvb, 0, size, ett_mapi_mapi_response, NULL, "Decrypted MAPI PDU");

View File

@ -80,7 +80,7 @@ unescape_data(tvbuff_t *tvb, packet_info *pinfo)
} else {
guint length = tvb_captured_length(tvb);
guint offset;
guint8 *data = (guint8 *)g_malloc(length);
guint8 *data = (guint8 *)wmem_alloc(pinfo->pool, length);
guint8 *dst = data;
tvbuff_t *next_tvb;
@ -93,7 +93,6 @@ unescape_data(tvbuff_t *tvb, packet_info *pinfo)
}
next_tvb = tvb_new_child_real_data(tvb, data, (guint) (dst-data), (guint) (dst-data));
tvb_set_free_cb(next_tvb, g_free);
add_new_data_source(pinfo, next_tvb, "Unescaped SIR");
return next_tvb;
}