Skip to content

Commit

Permalink
Convert the rest of the ASN1 dissectors from emem to wmem.
Browse files Browse the repository at this point in the history
svn path=/trunk/; revision=50063
  • Loading branch information
eapache committed Jun 19, 2013
1 parent 8e7abd9 commit b1e12ec
Show file tree
Hide file tree
Showing 19 changed files with 124 additions and 128 deletions.
20 changes: 10 additions & 10 deletions asn1/ldap/packet-ldap-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
#include <epan/conversation.h>
#include <epan/prefs.h>
#include <epan/tap.h>
#include <epan/emem.h>
#include <epan/wmem/wmem.h>
#include <epan/oids.h>
#include <epan/strutil.h>
#include <epan/show_exception.h>
Expand Down Expand Up @@ -408,13 +408,13 @@ attribute_types_update_cb(void *r, const char **err)
char c;

if (rec->attribute_type == NULL) {
*err = ep_strdup_printf("Attribute type can't be empty");
*err = wmem_strdup_printf(wmem_packet_scope(), "Attribute type can't be empty");
return;
}

g_strstrip(rec->attribute_type);
if (rec->attribute_type[0] == 0) {
*err = ep_strdup_printf("Attribute type can't be empty");
*err = wmem_strdup_printf(wmem_packet_scope(), "Attribute type can't be empty");
return;
}

Expand All @@ -423,7 +423,7 @@ attribute_types_update_cb(void *r, const char **err)
*/
c = proto_check_field_name(rec->attribute_type);
if (c) {
*err = ep_strdup_printf("Attribute type can't contain '%c'", c);
*err = wmem_strdup_printf(wmem_packet_scope(), "Attribute type can't contain '%c'", c);
return;
}

Expand Down Expand Up @@ -634,7 +634,7 @@ dissect_ldap_AssertionValue(gboolean implicit_tag, tvbuff_t *tvb, int offset, as
/* This octet string contained a GUID */
dissect_dcerpc_uuid_t(tvb, offset, actx->pinfo, tree, drep, hf_ldap_guid, &uuid);

ldapvalue_string=(char*)ep_alloc(1024);
ldapvalue_string=(char*)wmem_alloc(wmem_packet_scope(), 1024);
g_snprintf(ldapvalue_string, 1023, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
uuid.Data1, uuid.Data2, uuid.Data3,
uuid.Data4[0], uuid.Data4[1],
Expand All @@ -650,7 +650,7 @@ dissect_ldap_AssertionValue(gboolean implicit_tag, tvbuff_t *tvb, int offset, as
/* get flag value to populate ldapvalue_string */
flags=tvb_get_letohl(tvb, offset);

ldapvalue_string=(char*)ep_alloc(1024);
ldapvalue_string=(char*)wmem_alloc(wmem_packet_scope(), 1024);
g_snprintf(ldapvalue_string, 1023, "0x%08x",flags);

/* populate bitmask subtree */
Expand Down Expand Up @@ -684,9 +684,9 @@ dissect_ldap_AssertionValue(gboolean implicit_tag, tvbuff_t *tvb, int offset, as

/* convert the string into a printable string */
if(is_ascii){
ldapvalue_string=ep_strndup(str, len);
ldapvalue_string=wmem_strndup(wmem_packet_scope(), str, len);
} else {
ldapvalue_string=(char*)ep_alloc(3*len);
ldapvalue_string=(char*)wmem_alloc(wmem_packet_scope(), 3*len);
for(i=0;i<len;i++){
g_snprintf(ldapvalue_string+i*3,3,"%02x",str[i]&0xff);
ldapvalue_string[3*i+2]=':';
Expand Down Expand Up @@ -813,7 +813,7 @@ ldap_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gu
}
/* if we cant reuse the old one, grab a new chunk */
if(!lcrp){
lcrp=se_new(ldap_call_response_t);
lcrp=wmem_new(wmem_file_scope(), ldap_call_response_t);
}
lcrp->messageId=messageId;
lcrp->req_frame=pinfo->fd->num;
Expand Down Expand Up @@ -1778,7 +1778,7 @@ dissect_ldap_guid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* This octet string contained a GUID */
dissect_dcerpc_uuid_t(tvb, 0, pinfo, tree, drep, hf_ldap_guid, &uuid);

ldapvalue_string=(char*)ep_alloc(1024);
ldapvalue_string=(char*)wmem_alloc(wmem_packet_scope(), 1024);
g_snprintf(ldapvalue_string, 1023, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
uuid.Data1, uuid.Data2, uuid.Data3,
uuid.Data4[0], uuid.Data4[1],
Expand Down
1 change: 0 additions & 1 deletion asn1/m3ap/packet-m3ap-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <glib.h>
#include <epan/packet.h>

#include <epan/emem.h>
#include <epan/strutil.h>
#include <epan/asn1.h>
#include <epan/sctpppids.h>
Expand Down
6 changes: 3 additions & 3 deletions asn1/pres/packet-pres-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/conversation.h>
#include <epan/emem.h>
#include <epan/wmem/wmem.h>
#include <epan/expert.h>
#include <epan/uat.h>

Expand Down Expand Up @@ -141,9 +141,9 @@ register_ctx_id_and_oid(packet_info *pinfo _U_, guint32 idx, const char *oid)
return;
}

pco=se_new(pres_ctx_oid_t);
pco=wmem_new(wmem_file_scope(), pres_ctx_oid_t);
pco->ctx_id=idx;
pco->oid=se_strdup(oid);
pco->oid=wmem_strdup(wmem_file_scope(), oid);
conversation=find_conversation (pinfo->fd->num, &pinfo->src, &pinfo->dst,
pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
if (conversation) {
Expand Down
4 changes: 2 additions & 2 deletions asn1/ranap/packet-ranap-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <glib.h>
#include <epan/packet.h>

#include <epan/emem.h>
#include <epan/wmem/wmem.h>
#include <epan/strutil.h>
#include <epan/asn1.h>
#include <epan/prefs.h>
Expand Down Expand Up @@ -247,7 +247,7 @@ dissect_ranap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)

if (! sccp_msg_lcl->data.co.label && ProcedureCode != 0xFFFFFFFF) {
const gchar* str = val_to_str(ProcedureCode, ranap_ProcedureCode_vals,"Unknown RANAP");
sccp_msg_lcl->data.co.label = se_strdup(str);
sccp_msg_lcl->data.co.label = wmem_strdup(wmem_file_scope(), str);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions asn1/ros/packet-ros-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <glib.h>
#include <epan/packet.h>
#include <epan/conversation.h>
#include <epan/emem.h>
#include <epan/wmem/wmem.h>
#include <epan/asn1.h>
#include <epan/expert.h>

Expand Down Expand Up @@ -321,7 +321,7 @@ ros_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gui

/* if we cant reuse the old one, grab a new chunk */
if(!rcrp){
rcrp=se_new(ros_call_response_t);
rcrp=wmem_new(wmem_file_scope(), ros_call_response_t);
}
rcrp->invokeId=invokeId;
rcrp->req_frame=pinfo->fd->num;
Expand Down
1 change: 0 additions & 1 deletion asn1/sbc-ap/packet-sbc-ap-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

#include <stdio.h>
#include <string.h>
#include <epan/emem.h>
#include <epan/strutil.h>
#include <epan/asn1.h>
#include <epan/sctpppids.h>
Expand Down
62 changes: 31 additions & 31 deletions asn1/snmp/packet-snmp-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#include <epan/etypes.h>
#include <epan/prefs.h>
#include <epan/sminmpec.h>
#include <epan/emem.h>
#include <epan/wmem/wmem.h>
#include <epan/next_tvb.h>
#include <epan/uat.h>
#include <epan/asn1.h>
Expand Down Expand Up @@ -423,7 +423,7 @@ dissect_snmp_variable_date_and_time(proto_tree *tree,int hfid, tvbuff_t *tvb, in
hour_from_utc = tvb_get_guint8(tvb,offset+9);
min_from_utc = tvb_get_guint8(tvb,offset+10);

str = ep_strdup_printf("%u-%u-%u, %u:%u:%u.%u UTC %s%u:%u",
str = wmem_strdup_printf(wmem_packet_scope(), "%u-%u-%u, %u:%u:%u.%u UTC %s%u:%u",
year,
month,
day,
Expand All @@ -435,7 +435,7 @@ dissect_snmp_variable_date_and_time(proto_tree *tree,int hfid, tvbuff_t *tvb, in
hour_from_utc,
min_from_utc);
}else{
str = ep_strdup_printf("%u-%u-%u, %u:%u:%u.%u",
str = wmem_strdup_printf(wmem_packet_scope(), "%u-%u-%u, %u:%u:%u.%u",
year,
month,
day,
Expand Down Expand Up @@ -810,7 +810,7 @@ dissect_snmp_VarBind(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,
goto indexing_done;
}

buf = (guint8*)ep_alloc(buf_len+1);
buf = (guint8*)wmem_alloc(wmem_packet_scope(), buf_len+1);
for (i = 0; i < buf_len; i++)
buf[i] = (guint8)suboid[i];
buf[i] = '\0';
Expand Down Expand Up @@ -1039,21 +1039,21 @@ dissect_snmp_VarBind(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,

if (oid_info && oid_info->name) {
if (oid_left >= 1) {
repr = ep_strdup_printf("%s.%s (%s)", oid_info->name,
repr = wmem_strdup_printf(wmem_packet_scope(), "%s.%s (%s)", oid_info->name,
oid_subid2string(&(subids[oid_matched]),oid_left),
oid_subid2string(subids,oid_matched+oid_left));
info_oid = ep_strdup_printf("%s.%s", oid_info->name,
info_oid = wmem_strdup_printf(wmem_packet_scope(), "%s.%s", oid_info->name,
oid_subid2string(&(subids[oid_matched]),oid_left));
} else {
repr = ep_strdup_printf("%s (%s)", oid_info->name,
repr = wmem_strdup_printf(wmem_packet_scope(), "%s (%s)", oid_info->name,
oid_subid2string(subids,oid_matched));
info_oid = oid_info->name;
}
} else if (oid_string) {
repr = ep_strdup(oid_string);
repr = wmem_strdup(wmem_packet_scope(), oid_string);
info_oid = oid_string;
} else {
repr = ep_strdup("[Bad OID]");
repr = wmem_strdup(wmem_packet_scope(), "[Bad OID]");
}

valstr = strstr(label,": ");
Expand Down Expand Up @@ -1257,7 +1257,7 @@ dissect_snmp_engineid(proto_tree *tree, tvbuff_t *tvb, int offset, int len)
static void set_ue_keys(snmp_ue_assoc_t* n ) {
guint key_size = n->user.authModel->key_size;

n->user.authKey.data = (guint8 *)se_alloc(key_size);
n->user.authKey.data = (guint8 *)wmem_alloc(wmem_file_scope(), key_size);
n->user.authKey.len = key_size;
n->user.authModel->pass2key(n->user.authPassword.data,
n->user.authPassword.len,
Expand All @@ -1277,7 +1277,7 @@ static void set_ue_keys(snmp_ue_assoc_t* n ) {
while (key_len < need_key_len)
key_len += key_size;

n->user.privKey.data = (guint8 *)se_alloc(key_len);
n->user.privKey.data = (guint8 *)wmem_alloc(wmem_file_scope(), key_len);
n->user.privKey.len = need_key_len;

n->user.authModel->pass2key(n->user.privPassword.data,
Expand All @@ -1301,7 +1301,7 @@ static void set_ue_keys(snmp_ue_assoc_t* n ) {
}

} else {
n->user.privKey.data = (guint8 *)se_alloc(key_size);
n->user.privKey.data = (guint8 *)wmem_alloc(wmem_file_scope(), key_size);
n->user.privKey.len = key_size;
n->user.authModel->pass2key(n->user.privPassword.data,
n->user.privPassword.len,
Expand All @@ -1314,25 +1314,25 @@ static void set_ue_keys(snmp_ue_assoc_t* n ) {
static snmp_ue_assoc_t*
ue_se_dup(snmp_ue_assoc_t* o)
{
snmp_ue_assoc_t* d = (snmp_ue_assoc_t*)se_memdup(o,sizeof(snmp_ue_assoc_t));
snmp_ue_assoc_t* d = (snmp_ue_assoc_t*)wmem_memdup(wmem_file_scope(), o,sizeof(snmp_ue_assoc_t));

d->user.authModel = o->user.authModel;

d->user.privProtocol = o->user.privProtocol;

d->user.userName.data = (guint8 *)se_memdup(o->user.userName.data,o->user.userName.len);
d->user.userName.data = (guint8 *)wmem_memdup(wmem_file_scope(), o->user.userName.data,o->user.userName.len);
d->user.userName.len = o->user.userName.len;

d->user.authPassword.data = o->user.authPassword.data ? (guint8 *)se_memdup(o->user.authPassword.data,o->user.authPassword.len) : NULL;
d->user.authPassword.data = o->user.authPassword.data ? (guint8 *)wmem_memdup(wmem_file_scope(), o->user.authPassword.data,o->user.authPassword.len) : NULL;
d->user.authPassword.len = o->user.authPassword.len;

d->user.privPassword.data = o->user.privPassword.data ? (guint8 *)se_memdup(o->user.privPassword.data,o->user.privPassword.len) : NULL;
d->user.privPassword.data = o->user.privPassword.data ? (guint8 *)wmem_memdup(wmem_file_scope(), o->user.privPassword.data,o->user.privPassword.len) : NULL;
d->user.privPassword.len = o->user.privPassword.len;

d->engine.len = o->engine.len;

if (d->engine.len) {
d->engine.data = (guint8 *)se_memdup(o->engine.data,o->engine.len);
d->engine.data = (guint8 *)wmem_memdup(wmem_file_scope(), o->engine.data,o->engine.len);
set_ue_keys(d);
}

Expand Down Expand Up @@ -1370,9 +1370,9 @@ renew_ue_cache(void)
static snmp_ue_assoc_t*
localize_ue( snmp_ue_assoc_t* o, const guint8* engine, guint engine_len )
{
snmp_ue_assoc_t* n = (snmp_ue_assoc_t*)se_memdup(o,sizeof(snmp_ue_assoc_t));
snmp_ue_assoc_t* n = (snmp_ue_assoc_t*)wmem_memdup(wmem_file_scope(), o,sizeof(snmp_ue_assoc_t));

n->engine.data = (guint8*)se_memdup(engine,engine_len);
n->engine.data = (guint8*)wmem_memdup(wmem_file_scope(), engine,engine_len);
n->engine.len = engine_len;

set_ue_keys(n);
Expand Down Expand Up @@ -1479,7 +1479,7 @@ snmp_usm_auth_md5(snmp_usm_params_t* p, guint8** calc_auth_p, guint* calc_auth_l
msg[i] = '\0';
}

calc_auth = (guint8*)ep_alloc(16);
calc_auth = (guint8*)wmem_alloc(wmem_packet_scope(), 16);

md5_hmac(msg, msg_len, key, key_len, calc_auth);

Expand Down Expand Up @@ -1543,7 +1543,7 @@ snmp_usm_auth_sha1(snmp_usm_params_t* p _U_, guint8** calc_auth_p, guint* calc_a
msg[i] = '\0';
}

calc_auth = (guint8*)ep_alloc(20);
calc_auth = (guint8*)wmem_alloc(wmem_packet_scope(), 20);

sha1_hmac(key, key_len, msg, msg_len, calc_auth);

Expand Down Expand Up @@ -1597,7 +1597,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*)wmem_alloc(wmem_packet_scope(), 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 Down Expand Up @@ -1667,7 +1667,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*)wmem_alloc(wmem_packet_scope(), cryptgrm_len);

err = gcry_cipher_open(&hd, algo, GCRY_CIPHER_MODE_CFB, 0);
if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;
Expand Down Expand Up @@ -2226,7 +2226,7 @@ static void
snmp_users_update_cb(void* p _U_, const char** err)
{
snmp_ue_assoc_t* ue = (snmp_ue_assoc_t*)p;
emem_strbuf_t* es = ep_strbuf_new("");
wmem_strbuf_t* es = wmem_strbuf_new(wmem_packet_scope(), "");
unsigned int i;

*err = NULL;
Expand All @@ -2236,14 +2236,14 @@ snmp_users_update_cb(void* p _U_, const char** err)
return;

if (! ue->user.userName.len)
ep_strbuf_append_printf(es,"no userName\n");
wmem_strbuf_append_printf(es,"no userName\n");

for (i=0; i<num_ueas-1; i++) {
snmp_ue_assoc_t* u = &(ueas[i]);

/* RFC 3411 section 5 */
if ((u->engine.len > 0) && (u->engine.len < 5 || u->engine.len > 32)) {
ep_strbuf_append_printf(es, "Invalid engineId length (%u). Must be between 5 and 32 (10 and 64 hex digits)\n", u->engine.len);
wmem_strbuf_append_printf(es, "Invalid engineId length (%u). Must be between 5 and 32 (10 and 64 hex digits)\n", u->engine.len);
}


Expand All @@ -2253,21 +2253,21 @@ snmp_users_update_cb(void* p _U_, const char** err)
if (u->engine.len > 0 && memcmp( u->engine.data, ue->engine.data, u->engine.len ) == 0) {
if ( memcmp( u->user.userName.data, ue->user.userName.data, ue->user.userName.len ) == 0 ) {
/* XXX: make a string for the engineId */
ep_strbuf_append_printf(es,"Duplicate key (userName='%s')\n",ue->user.userName.data);
wmem_strbuf_append_printf(es,"Duplicate key (userName='%s')\n",ue->user.userName.data);
}
}

if (u->engine.len == 0) {
if ( memcmp( u->user.userName.data, ue->user.userName.data, ue->user.userName.len ) == 0 ) {
ep_strbuf_append_printf(es,"Duplicate key (userName='%s' engineId=NONE)\n",ue->user.userName.data);
wmem_strbuf_append_printf(es,"Duplicate key (userName='%s' engineId=NONE)\n",ue->user.userName.data);
}
}
}
}

if (es->len) {
es = ep_strbuf_truncate(es,es->len-1);
*err = ep_strdup(es->str);
if (wmem_strbuf_get_len(es)) {
wmem_strbuf_truncate(es,wmem_strbuf_get_len(es)-1);
*err = wmem_strdup(wmem_packet_scope(), wmem_strbuf_get_str(es));
}

return;
Expand Down
4 changes: 2 additions & 2 deletions asn1/spnego/packet-spnego-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "packet-kerberos.h"
#include <epan/crypt/rc4.h>
#include <epan/conversation.h>
#include <epan/emem.h>
#include <epan/wmem/wmem.h>
#include <epan/asn1.h>

#include <string.h>
Expand Down Expand Up @@ -592,7 +592,7 @@ decrypt_gssapi_krb_arcfour_wrap(proto_tree *tree, packet_info *pinfo, tvbuff_t *
/* XXX we should only do this for first time, then store somewhere */
/* XXX We also need to re-read the keytab when the preference changes */

cryptocopy=(guint8 *)ep_alloc(length);
cryptocopy=(guint8 *)wmem_alloc(wmem_packet_scope(), length);
if(output_message_buffer){
g_free(output_message_buffer);
output_message_buffer=NULL;
Expand Down
Loading

0 comments on commit b1e12ec

Please sign in to comment.