c1222: Free uat table records

Add c1222_uat_data copy and free callbacks

Change-Id: I43a737db72ea826aab18960247784d4927fe3ec5
Reviewed-on: https://code.wireshark.org/review/30505
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
Vasil Velichkov 2018-11-03 22:38:12 +02:00 committed by Peter Wu
parent d98139182e
commit bb73b82672
2 changed files with 47 additions and 7 deletions

View File

@ -709,6 +709,19 @@ encode_ber_len(guint8 *ptr, guint32 n, int maxsize)
}
static void*
c1222_uat_data_copy_cb(void *dest, const void *source, size_t len _U_)
{
const c1222_uat_data_t* o = (const c1222_uat_data_t*)source;
c1222_uat_data_t* d = (c1222_uat_data_t*)dest;
d->keynum = o->keynum;
d->keylen = o->keylen;
d->key = (guchar *)g_memdup(o->key, o->keylen);
return dest;
}
/**
* Checks a new encryption table item for validity.
*
@ -732,6 +745,13 @@ c1222_uat_data_update_cb(void* n, char** err)
return TRUE;
}
static void
c1222_uat_data_free_cb(void *r)
{
c1222_uat_data_t *rec = (c1222_uat_data_t *)r;
g_free(rec->key);
}
/**
* Canonifies header fields in preparation for authenticating and/or decrypting the packet.
*
@ -1396,9 +1416,9 @@ void proto_register_c1222(void) {
&num_c1222_uat_data, /* numitems_ptr */
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
NULL, /* help */
NULL, /* copy callback */
c1222_uat_data_copy_cb, /* copy callback */
c1222_uat_data_update_cb, /* update callback */
NULL, /* free callback */
c1222_uat_data_free_cb, /* free callback */
NULL, /* post update callback */
NULL, /* reset callback */
c1222_uat_flds); /* UAT field definitions */

View File

@ -760,6 +760,19 @@ encode_ber_len(guint8 *ptr, guint32 n, int maxsize)
}
static void*
c1222_uat_data_copy_cb(void *dest, const void *source, size_t len _U_)
{
const c1222_uat_data_t* o = (const c1222_uat_data_t*)source;
c1222_uat_data_t* d = (c1222_uat_data_t*)dest;
d->keynum = o->keynum;
d->keylen = o->keylen;
d->key = (guchar *)g_memdup(o->key, o->keylen);
return dest;
}
/**
* Checks a new encryption table item for validity.
*
@ -783,6 +796,13 @@ c1222_uat_data_update_cb(void* n, char** err)
return TRUE;
}
static void
c1222_uat_data_free_cb(void *r)
{
c1222_uat_data_t *rec = (c1222_uat_data_t *)r;
g_free(rec->key);
}
/**
* Canonifies header fields in preparation for authenticating and/or decrypting the packet.
*
@ -1545,7 +1565,7 @@ static int dissect_MESSAGE_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_
/*--- End of included file: packet-c1222-fn.c ---*/
#line 1029 "./asn1/c1222/packet-c1222-template.c"
#line 1049 "./asn1/c1222/packet-c1222-template.c"
/**
* Dissects a a full (reassembled) C12.22 message.
@ -1955,7 +1975,7 @@ void proto_register_c1222(void) {
"OCTET_STRING_SIZE_CONSTR002", HFILL }},
/*--- End of included file: packet-c1222-hfarr.c ---*/
#line 1334 "./asn1/c1222/packet-c1222-template.c"
#line 1354 "./asn1/c1222/packet-c1222-template.c"
};
/* List of subtrees */
@ -1978,7 +1998,7 @@ void proto_register_c1222(void) {
&ett_c1222_Calling_authentication_value_c1221_U,
/*--- End of included file: packet-c1222-ettarr.c ---*/
#line 1344 "./asn1/c1222/packet-c1222-template.c"
#line 1364 "./asn1/c1222/packet-c1222-template.c"
};
static ei_register_info ei[] = {
@ -2034,9 +2054,9 @@ void proto_register_c1222(void) {
&num_c1222_uat_data, /* numitems_ptr */
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
NULL, /* help */
NULL, /* copy callback */
c1222_uat_data_copy_cb, /* copy callback */
c1222_uat_data_update_cb, /* update callback */
NULL, /* free callback */
c1222_uat_data_free_cb, /* free callback */
NULL, /* post update callback */
NULL, /* reset callback */
c1222_uat_flds); /* UAT field definitions */