summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asn1/c1222/packet-c1222-template.c3
-rw-r--r--asn1/cdt/cdt.cnf2
-rw-r--r--asn1/cms/cms.cnf6
-rw-r--r--asn1/dop/packet-dop-template.c2
-rw-r--r--asn1/ldap/ldap.cnf4
-rw-r--r--asn1/ldap/packet-ldap-template.c2
-rw-r--r--asn1/p1/p1.cnf6
-rw-r--r--asn1/p22/p22.cnf2
-rw-r--r--asn1/pkcs12/packet-pkcs12-template.c4
-rw-r--r--asn1/pres/pres.cnf2
-rw-r--r--asn1/snmp/packet-snmp-template.c16
-rw-r--r--asn1/snmp/snmp.cnf2
-rw-r--r--asn1/x509af/x509af.cnf4
-rw-r--r--asn1/x509if/x509if.cnf4
-rw-r--r--epan/dissectors/packet-ber.c6
-rw-r--r--epan/dissectors/packet-c1222.c3
-rw-r--r--epan/dissectors/packet-cdt.c2
-rw-r--r--epan/dissectors/packet-cms.c6
-rw-r--r--epan/dissectors/packet-cops.c6
-rw-r--r--epan/dissectors/packet-dop.c2
-rw-r--r--epan/dissectors/packet-ldap.c6
-rw-r--r--epan/dissectors/packet-p1.c6
-rw-r--r--epan/dissectors/packet-p22.c2
-rw-r--r--epan/dissectors/packet-per.c4
-rw-r--r--epan/dissectors/packet-pkcs12.c4
-rw-r--r--epan/dissectors/packet-pres.c2
-rw-r--r--epan/dissectors/packet-snmp.c18
-rw-r--r--epan/dissectors/packet-x509af.c4
-rw-r--r--epan/dissectors/packet-x509if.c4
-rw-r--r--epan/ftypes/ftype-bytes.c10
-rw-r--r--epan/oids.c215
-rw-r--r--epan/oids.h32
-rw-r--r--epan/oids_test.c131
-rw-r--r--epan/proto.c54
34 files changed, 322 insertions, 254 deletions
diff --git a/asn1/c1222/packet-c1222-template.c b/asn1/c1222/packet-c1222-template.c
index 15e9287e63..47c69aca6b 100644
--- a/asn1/c1222/packet-c1222-template.c
+++ b/asn1/c1222/packet-c1222-template.c
@@ -1418,9 +1418,10 @@ proto_reg_handoff_c1222(void)
dissector_add_uint("udp.port", global_c1222_port, c1222_udp_handle);
initialized = TRUE;
}
- c1222_baseoid_len = oid_string2encoded(c1222_baseoid_str, &temp);
+ c1222_baseoid_len = oid_string2encoded(NULL, c1222_baseoid_str, &temp);
c1222_baseoid = (guint8 *)wmem_realloc(wmem_epan_scope(), c1222_baseoid, c1222_baseoid_len);
memcpy(c1222_baseoid, temp, c1222_baseoid_len);
+ wmem_free(NULL, temp);
}
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
diff --git a/asn1/cdt/cdt.cnf b/asn1/cdt/cdt.cnf
index 071524269c..e2bc316770 100644
--- a/asn1/cdt/cdt.cnf
+++ b/asn1/cdt/cdt.cnf
@@ -49,7 +49,7 @@ CompressedData B "1.3.26.0.4406.0.4.2" "cdt"
%(DEFAULT_BODY)s
if (obj_id) {
- const char *name = oid_resolved_from_string (obj_id);
+ const char *name = oid_resolved_from_string (wmem_packet_scope(), obj_id);
if (!name) {
name = obj_id;
diff --git a/asn1/cms/cms.cnf b/asn1/cms/cms.cnf
index ece91a13a7..50b09fffd8 100644
--- a/asn1/cms/cms.cnf
+++ b/asn1/cms/cms.cnf
@@ -90,7 +90,7 @@ RevocationInfoChoice/other otherRIC
%(DEFAULT_BODY)s
if(object_identifier_id) {
- name = oid_resolved_from_string(object_identifier_id);
+ name = oid_resolved_from_string(wmem_packet_scope(), object_identifier_id);
proto_item_append_text(tree, " (%%s)", name ? name : object_identifier_id);
}
@@ -131,7 +131,7 @@ RevocationInfoChoice/other otherRIC
%(DEFAULT_BODY)s
if(object_identifier_id) {
- name = oid_resolved_from_string(object_identifier_id);
+ name = oid_resolved_from_string(wmem_packet_scope(), object_identifier_id);
proto_item_append_text(tree, " (%%s)", name ? name : object_identifier_id);
}
@@ -163,7 +163,7 @@ RevocationInfoChoice/other otherRIC
%(DEFAULT_BODY)s
if(object_identifier_id) {
- name = oid_resolved_from_string(object_identifier_id);
+ name = oid_resolved_from_string(wmem_packet_scope(), object_identifier_id);
proto_item_append_text(tree, " %%s", name ? name : object_identifier_id);
cap_tree = tree;
}
diff --git a/asn1/dop/packet-dop-template.c b/asn1/dop/packet-dop-template.c
index 99620d8f5d..ceb022c98f 100644
--- a/asn1/dop/packet-dop-template.c
+++ b/asn1/dop/packet-dop-template.c
@@ -81,7 +81,7 @@ static void append_oid(packet_info *pinfo, const char *oid)
{
const char *name = NULL;
- name = oid_resolved_from_string(oid);
+ name = oid_resolved_from_string(wmem_packet_scope(), oid);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name ? name : oid);
}
diff --git a/asn1/ldap/ldap.cnf b/asn1/ldap/ldap.cnf
index 78bc8fd066..40b67c4839 100644
--- a/asn1/ldap/ldap.cnf
+++ b/asn1/ldap/ldap.cnf
@@ -67,7 +67,7 @@ PasswordPolicyResponseValue B "1.3.6.1.4.1.42.2.27.8.5.1" "passwordPolicy"
return offset;
object_identifier_id = tvb_get_string_enc(wmem_packet_scope(), parameter_tvb, 0, tvb_length_remaining(parameter_tvb,0), ENC_UTF_8|ENC_NA);
- name = oid_resolved_from_string(object_identifier_id);
+ name = oid_resolved_from_string(wmem_packet_scope(), object_identifier_id);
if(name){
proto_item_append_text(actx->created_item, " (%s)", name);
@@ -758,7 +758,7 @@ offset = dissect_ber_boolean(implicit_tag, actx, tree, tvb, offset, hf_index, &v
#.FN_BODY IntermediateResponse/_untag/responseValue
if(ldm_tree && object_identifier_id) {
proto_item_set_text(ldm_tree, "%%s %%s", "IntermediateResponse", object_identifier_id);
- name = oid_resolved_from_string(object_identifier_id);
+ name = oid_resolved_from_string(wmem_packet_scope(), object_identifier_id);
if(name)
proto_item_append_text(ldm_tree, " (%%s)", name);
}
diff --git a/asn1/ldap/packet-ldap-template.c b/asn1/ldap/packet-ldap-template.c
index 42574bda81..d5dccc94c7 100644
--- a/asn1/ldap/packet-ldap-template.c
+++ b/asn1/ldap/packet-ldap-template.c
@@ -1670,7 +1670,7 @@ dissect_ldap_oid(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
return;
}
- oidname=oid_resolved_from_string(oid);
+ oidname=oid_resolved_from_string(wmem_packet_scope(), oid);
if(oidname){
proto_tree_add_string_format_value(tree, hf_ldap_oid, tvb, 0, tvb_reported_length(tvb), oid, "%s (%s)",oid,oidname);
diff --git a/asn1/p1/p1.cnf b/asn1/p1/p1.cnf
index 7dbedb3c30..4ac72fd154 100644
--- a/asn1/p1/p1.cnf
+++ b/asn1/p1/p1.cnf
@@ -551,7 +551,7 @@ MessageToken B "2.6.1.7.36" "id-hat-forwarded-token"
}
} else if (actx->external.direct_ref_present) {
offset = call_ber_oid_callback(actx->external.direct_reference, tvb, offset, actx->pinfo, tree, actx->private_data);
- name = oid_resolved_from_string(actx->external.direct_reference);
+ name = oid_resolved_from_string(wmem_packet_scope(), actx->external.direct_reference);
proto_item_append_text(tree, " (%%s)", name ? name : actx->external.direct_reference);
}
@@ -564,7 +564,7 @@ MessageToken B "2.6.1.7.36" "id-hat-forwarded-token"
if (actx->external.direct_reference) {
offset = call_ber_oid_callback(actx->external.direct_reference, tvb, offset, actx->pinfo, tree, actx->private_data);
- name = oid_resolved_from_string(actx->external.direct_reference);
+ name = oid_resolved_from_string(wmem_packet_scope(), actx->external.direct_reference);
proto_item_append_text(tree, " (%%s)", name ? name : actx->external.direct_reference);
} else {
offset = dissect_unknown_ber(actx->pinfo, tvb, offset, tree);
@@ -630,7 +630,7 @@ MessageToken B "2.6.1.7.36" "id-hat-forwarded-token"
%(DEFAULT_BODY)s
if(ctx->content_type_id) {
- name = oid_resolved_from_string(ctx->content_type_id);
+ name = oid_resolved_from_string(wmem_packet_scope(), ctx->content_type_id);
if(!name) name = ctx->content_type_id;
diff --git a/asn1/p22/p22.cnf b/asn1/p22/p22.cnf
index d28550d708..92f57c8ba6 100644
--- a/asn1/p22/p22.cnf
+++ b/asn1/p22/p22.cnf
@@ -221,7 +221,7 @@ IpnSecurityResponse B "2.6.1.18.1" "id-sec-security-common-fields"
%(DEFAULT_BODY)s
- name = oid_resolved_from_string(actx->external.direct_reference);
+ name = oid_resolved_from_string(wmem_packet_scope(), actx->external.direct_reference);
proto_item_append_text(tree, " (%%s)", name ? name : actx->external.direct_reference);
#.FN_BODY IPMSExtension/value
diff --git a/asn1/pkcs12/packet-pkcs12-template.c b/asn1/pkcs12/packet-pkcs12-template.c
index 543a86e6db..63d09b04fa 100644
--- a/asn1/pkcs12/packet-pkcs12-template.c
+++ b/asn1/pkcs12/packet-pkcs12-template.c
@@ -86,7 +86,7 @@ static void append_oid(proto_tree *tree, const char *oid)
{
const char *name = NULL;
- name = oid_resolved_from_string(oid);
+ name = oid_resolved_from_string(wmem_packet_scope(), oid);
proto_item_append_text(tree, " (%s)", name ? name : oid);
}
@@ -369,7 +369,7 @@ int PBE_decrypt_data(const char *object_identifier_id_param, tvbuff_t *encrypted
tvb_set_free_cb(clear_tvb, g_free);
name = g_string_new("");
- oidname = oid_resolved_from_string(object_identifier_id_param);
+ oidname = oid_resolved_from_string(wmem_packet_scope(), object_identifier_id_param);
g_string_printf(name, "Decrypted %s", oidname ? oidname : object_identifier_id_param);
/* add it as a new source */
diff --git a/asn1/pres/pres.cnf b/asn1/pres/pres.cnf
index f7129a8edf..725a8946f0 100644
--- a/asn1/pres/pres.cnf
+++ b/asn1/pres/pres.cnf
@@ -79,7 +79,7 @@ CPR-PPDU/normal-mode-parameters/provider-reason cPR_PPDU__provider-reason
oid = find_oid_by_pres_ctx_id(actx->pinfo, presentation_context_identifier);
- if(oid && (name = oid_resolved_from_string(oid))) {
+ if(oid && (name = oid_resolved_from_string(wmem_packet_scope(), oid))) {
proto_item_append_text(actx->created_item, " (%%s)", name);
}
diff --git a/asn1/snmp/packet-snmp-template.c b/asn1/snmp/packet-snmp-template.c
index cfeafd8d23..222ffc3ead 100644
--- a/asn1/snmp/packet-snmp-template.c
+++ b/asn1/snmp/packet-snmp-template.c
@@ -607,21 +607,21 @@ dissect_snmp_VarBind(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,
/* fetch ObjectName and its relative oid_info */
oid_bytes = (guint8*)tvb_memdup(wmem_packet_scope(), tvb, name_offset, name_len);
- oid_info = oid_get_from_encoded(oid_bytes, name_len, &subids, &oid_matched, &oid_left);
+ oid_info = oid_get_from_encoded(wmem_packet_scope(), oid_bytes, name_len, &subids, &oid_matched, &oid_left);
add_oid_debug_subtree(oid_info,pt_name);
if (!subids) {
proto_item* pi;
- repr = oid_encoded2string(oid_bytes, name_len);
+ repr = oid_encoded2string(wmem_packet_scope(), oid_bytes, name_len);
pt = proto_tree_add_subtree_format(pt_name,tvb, 0, 0, ett_decoding_error, &pi, "invalid oid: %s", repr);
expert_add_info_format(actx->pinfo, pi, &ei_snmp_invalid_oid, "invalid oid: %s", repr);
return dissect_unknown_ber(actx->pinfo, tvb, name_offset, pt);
}
if (oid_matched+oid_left) {
- oid_string = oid_subid2string(subids,oid_matched+oid_left);
+ oid_string = oid_subid2string(wmem_packet_scope(), subids,oid_matched+oid_left);
}
if (ber_class == BER_CLASS_CON) {
@@ -752,7 +752,7 @@ show_oid_index:
goto indexing_done;
}
- suboid_buf_len = oid_subid2encoded(suboid_len, suboid, &suboid_buf);
+ suboid_buf_len = oid_subid2encoded(wmem_packet_scope(), suboid_len, suboid, &suboid_buf);
DISSECTOR_ASSERT(suboid_buf_len);
@@ -1020,13 +1020,13 @@ set_label:
if (oid_info && oid_info->name) {
if (oid_left >= 1) {
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));
+ oid_subid2string(wmem_packet_scope(), &(subids[oid_matched]),oid_left),
+ oid_subid2string(wmem_packet_scope(), subids,oid_matched+oid_left));
info_oid = wmem_strdup_printf(wmem_packet_scope(), "%s.%s", oid_info->name,
- oid_subid2string(&(subids[oid_matched]),oid_left));
+ oid_subid2string(wmem_packet_scope(), &(subids[oid_matched]),oid_left));
} else {
repr = wmem_strdup_printf(wmem_packet_scope(), "%s (%s)", oid_info->name,
- oid_subid2string(subids,oid_matched));
+ oid_subid2string(wmem_packet_scope(), subids,oid_matched));
info_oid = oid_info->name;
}
} else if (oid_string) {
diff --git a/asn1/snmp/snmp.cnf b/asn1/snmp/snmp.cnf
index 22e1ac3150..715a1b6934 100644
--- a/asn1/snmp/snmp.cnf
+++ b/asn1/snmp/snmp.cnf
@@ -70,7 +70,7 @@ gint pdu_type=-1;
%(DEFAULT_BODY)s
if (display_oid && enterprise_oid) {
- name = oid_resolved_from_string(enterprise_oid);
+ name = oid_resolved_from_string(wmem_packet_scope(), enterprise_oid);
if (name) {
col_append_fstr (actx->pinfo->cinfo, COL_INFO, " %%s", name);
}
diff --git a/asn1/x509af/x509af.cnf b/asn1/x509af/x509af.cnf
index 8791a982c5..e0e6a82166 100644
--- a/asn1/x509af/x509af.cnf
+++ b/asn1/x509af/x509af.cnf
@@ -73,7 +73,7 @@ CertificateList/signedCertificateList/revokedCertificates/_item/userCertificate
algorithm_id = actx->external.direct_reference;
if(actx->external.direct_reference) {
- name = oid_resolved_from_string(actx->external.direct_reference);
+ name = oid_resolved_from_string(wmem_packet_scope(), actx->external.direct_reference);
proto_item_append_text(tree, " (%%s)", name ? name : actx->external.direct_reference);
}
@@ -90,7 +90,7 @@ CertificateList/signedCertificateList/revokedCertificates/_item/userCertificate
%(DEFAULT_BODY)s
if(actx->external.direct_reference) {
- name = oid_resolved_from_string(actx->external.direct_reference);
+ name = oid_resolved_from_string(wmem_packet_scope(), actx->external.direct_reference);
proto_item_append_text(tree, " (%%s)", name ? name : actx->external.direct_reference);
}
diff --git a/asn1/x509if/x509if.cnf b/asn1/x509if/x509if.cnf
index 17e26a38e3..0c4137f7a7 100644
--- a/asn1/x509if/x509if.cnf
+++ b/asn1/x509if/x509if.cnf
@@ -194,7 +194,7 @@ DistinguishedName B "2.16.840.1.101.2.2.1.188" "id-at-primaryMember"
if(actx->external.direct_reference) {
/* see if we can find a nice name */
- name = oid_resolved_from_string(actx->external.direct_reference);
+ name = oid_resolved_from_string(wmem_packet_scope(), actx->external.direct_reference);
if(!name) name = actx->external.direct_reference;
if(last_rdn) { /* append it to the RDN */
@@ -258,7 +258,7 @@ DistinguishedName B "2.16.840.1.101.2.2.1.188" "id-at-primaryMember"
last_ava = (char *)wmem_alloc(wmem_packet_scope(), MAX_AVA_STR_LEN);
}
- if(!(name = oid_resolved_from_string(actx->external.direct_reference)))
+ if(!(name = oid_resolved_from_string(wmem_packet_scope(), actx->external.direct_reference)))
name = actx->external.direct_reference;
g_snprintf(last_ava, MAX_AVA_STR_LEN, "%%s %%s %%s", name, fmt, value);
diff --git a/epan/dissectors/packet-ber.c b/epan/dissectors/packet-ber.c
index 6784dc0048..09679f238f 100644
--- a/epan/dissectors/packet-ber.c
+++ b/epan/dissectors/packet-ber.c
@@ -3201,11 +3201,11 @@ printf("OBJECT IDENTIFIER dissect_ber_any_oid(%s) entered\n", name);
if ((is_absolute && hfi->type == FT_OID) || (!is_absolute && hfi->type == FT_REL_OID)) {
actx->created_item = proto_tree_add_item(tree, hf_id, tvb, offset, len, ENC_BIG_ENDIAN);
} else if (IS_FT_STRING(hfi->type)) {
- str = oid_encoded2string(tvb_get_ptr(tvb, offset, len), len);
+ str = oid_encoded2string(wmem_packet_scope(), tvb_get_ptr(tvb, offset, len), len);
actx->created_item = proto_tree_add_string(tree, hf_id, tvb, offset, len, str);
if (actx->created_item) {
/* see if we know the name of this oid */
- name = oid_resolved_from_encoded(tvb_get_ptr(tvb, offset, len), len);
+ name = oid_resolved_from_encoded(wmem_packet_scope(), tvb_get_ptr(tvb, offset, len), len);
if (name) {
proto_item_append_text(actx->created_item, " (%s)", name);
}
@@ -3230,7 +3230,7 @@ dissect_ber_any_oid_str(gboolean implicit_tag, asn1_ctx_t *actx, proto_tree *tre
if (value_stringx) {
if (value_tvb && (length = tvb_reported_length(value_tvb))) {
- *value_stringx = oid_encoded2string(tvb_get_ptr(value_tvb, 0, length), length);
+ *value_stringx = oid_encoded2string(wmem_packet_scope(), tvb_get_ptr(value_tvb, 0, length), length);
} else {
*value_stringx = "";
}
diff --git a/epan/dissectors/packet-c1222.c b/epan/dissectors/packet-c1222.c
index aa864c4605..dc0b4480ef 100644
--- a/epan/dissectors/packet-c1222.c
+++ b/epan/dissectors/packet-c1222.c
@@ -2058,9 +2058,10 @@ proto_reg_handoff_c1222(void)
dissector_add_uint("udp.port", global_c1222_port, c1222_udp_handle);
initialized = TRUE;
}
- c1222_baseoid_len = oid_string2encoded(c1222_baseoid_str, &temp);
+ c1222_baseoid_len = oid_string2encoded(NULL, c1222_baseoid_str, &temp);
c1222_baseoid = (guint8 *)wmem_realloc(wmem_epan_scope(), c1222_baseoid, c1222_baseoid_len);
memcpy(c1222_baseoid, temp, c1222_baseoid_len);
+ wmem_free(NULL, temp);
}
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
diff --git a/epan/dissectors/packet-cdt.c b/epan/dissectors/packet-cdt.c
index 85bdb1d014..09873bea8e 100644
--- a/epan/dissectors/packet-cdt.c
+++ b/epan/dissectors/packet-cdt.c
@@ -201,7 +201,7 @@ dissect_cdt_T_contentType_OID(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int
offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &obj_id);
if (obj_id) {
- const char *name = oid_resolved_from_string (obj_id);
+ const char *name = oid_resolved_from_string (wmem_packet_scope(), obj_id);
if (!name) {
name = obj_id;
diff --git a/epan/dissectors/packet-cms.c b/epan/dissectors/packet-cms.c
index 8a6fda0957..3af16d65c9 100644
--- a/epan/dissectors/packet-cms.c
+++ b/epan/dissectors/packet-cms.c
@@ -338,7 +338,7 @@ dissect_cms_ContentType(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset
if(object_identifier_id) {
- name = oid_resolved_from_string(object_identifier_id);
+ name = oid_resolved_from_string(wmem_packet_scope(), object_identifier_id);
proto_item_append_text(tree, " (%s)", name ? name : object_identifier_id);
}
@@ -466,7 +466,7 @@ dissect_cms_T_attrType(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset
if(object_identifier_id) {
- name = oid_resolved_from_string(object_identifier_id);
+ name = oid_resolved_from_string(wmem_packet_scope(), object_identifier_id);
proto_item_append_text(tree, " (%s)", name ? name : object_identifier_id);
}
@@ -1643,7 +1643,7 @@ dissect_cms_T_capability(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offse
if(object_identifier_id) {
- name = oid_resolved_from_string(object_identifier_id);
+ name = oid_resolved_from_string(wmem_packet_scope(), object_identifier_id);
proto_item_append_text(tree, " %s", name ? name : object_identifier_id);
cap_tree = tree;
}
diff --git a/epan/dissectors/packet-cops.c b/epan/dissectors/packet-cops.c
index b34a09d3fe..2d619c678e 100644
--- a/epan/dissectors/packet-cops.c
+++ b/epan/dissectors/packet-cops.c
@@ -1579,7 +1579,7 @@ static int dissect_cops_pr_object_data(tvbuff_t *tvb, packet_info *pinfo, guint3
encoid_len = tvb_length_remaining(oid_tvb,0);
if (encoid_len > 0) {
encoid = (guint8*)tvb_memdup(wmem_packet_scope(),oid_tvb,0,encoid_len);
- (*pprid_subids_len) = oid_encoded2subid(encoid, encoid_len, pprid_subids);
+ (*pprid_subids_len) = oid_encoded2subid(wmem_packet_scope(), encoid, encoid_len, pprid_subids);
}
}
break;
@@ -1610,9 +1610,9 @@ static int dissect_cops_pr_object_data(tvbuff_t *tvb, packet_info *pinfo, guint3
if (*pprid_subids) {
/* Never tested this branch */
subids_len = redecode_oid(*pprid_subids, *pprid_subids_len, encoid, encoid_len, &subids);
- encoid_len = oid_subid2encoded(subids_len, subids, &encoid);
+ encoid_len = oid_subid2encoded(wmem_packet_scope(), subids_len, subids, &encoid);
} else {
- subids_len = oid_encoded2subid(encoid, encoid_len, &subids);
+ subids_len = oid_encoded2subid(wmem_packet_scope(), encoid, encoid_len, &subids);
}
proto_tree_add_oid(asn_tree,hf_cops_prid_oid,tvb,offset,encoid_len,encoid);
diff --git a/epan/dissectors/packet-dop.c b/epan/dissectors/packet-dop.c
index 42c1007b00..84111ca9ba 100644
--- a/epan/dissectors/packet-dop.c
+++ b/epan/dissectors/packet-dop.c
@@ -357,7 +357,7 @@ static void append_oid(packet_info *pinfo, const char *oid)
{
const char *name = NULL;
- name = oid_resolved_from_string(oid);
+ name = oid_resolved_from_string(wmem_packet_scope(), oid);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name ? name : oid);
}
diff --git a/epan/dissectors/packet-ldap.c b/epan/dissectors/packet-ldap.c
index 430675d8bf..74ed9075e1 100644
--- a/epan/dissectors/packet-ldap.c
+++ b/epan/dissectors/packet-ldap.c
@@ -2860,7 +2860,7 @@ dissect_ldap_LDAPOID(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U
return offset;
object_identifier_id = tvb_get_string_enc(wmem_packet_scope(), parameter_tvb, 0, tvb_length_remaining(parameter_tvb,0), ENC_UTF_8|ENC_NA);
- name = oid_resolved_from_string(object_identifier_id);
+ name = oid_resolved_from_string(wmem_packet_scope(), object_identifier_id);
if(name){
proto_item_append_text(actx->created_item, " (%s)", name);
@@ -3054,7 +3054,7 @@ dissect_ldap_T_intermediateResponse_responseValue(gboolean implicit_tag _U_, tvb
#line 759 "../../asn1/ldap/ldap.cnf"
if(ldm_tree && object_identifier_id) {
proto_item_set_text(ldm_tree, "%s %s", "IntermediateResponse", object_identifier_id);
- name = oid_resolved_from_string(object_identifier_id);
+ name = oid_resolved_from_string(wmem_packet_scope(), object_identifier_id);
if(name)
proto_item_append_text(ldm_tree, " (%s)", name);
}
@@ -4608,7 +4608,7 @@ dissect_ldap_oid(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
return;
}
- oidname=oid_resolved_from_string(oid);
+ oidname=oid_resolved_from_string(wmem_packet_scope(), oid);
if(oidname){
proto_tree_add_string_format_value(tree, hf_ldap_oid, tvb, 0, tvb_reported_length(tvb), oid, "%s (%s)",oid,oidname);
diff --git a/epan/dissectors/packet-p1.c b/epan/dissectors/packet-p1.c
index aa8891faed..38c32c694b 100644
--- a/epan/dissectors/packet-p1.c
+++ b/epan/dissectors/packet-p1.c
@@ -1242,7 +1242,7 @@ dissect_p1_SecurityCategoryValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, i
if (actx->external.direct_reference) {
offset = call_ber_oid_callback(actx->external.direct_reference, tvb, offset, actx->pinfo, tree, actx->private_data);
- name = oid_resolved_from_string(actx->external.direct_reference);
+ name = oid_resolved_from_string(wmem_packet_scope(), actx->external.direct_reference);
proto_item_append_text(tree, " (%s)", name ? name : actx->external.direct_reference);
} else {
offset = dissect_unknown_ber(actx->pinfo, tvb, offset, tree);
@@ -2540,7 +2540,7 @@ dissect_p1_ExtendedContentType(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int
if(ctx->content_type_id) {
- name = oid_resolved_from_string(ctx->content_type_id);
+ name = oid_resolved_from_string(wmem_packet_scope(), ctx->content_type_id);
if(!name) name = ctx->content_type_id;
@@ -3057,7 +3057,7 @@ dissect_p1_ExtensionValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offs
}
} else if (actx->external.direct_ref_present) {
offset = call_ber_oid_callback(actx->external.direct_reference, tvb, offset, actx->pinfo, tree, actx->private_data);
- name = oid_resolved_from_string(actx->external.direct_reference);
+ name = oid_resolved_from_string(wmem_packet_scope(), actx->external.direct_reference);
proto_item_append_text(tree, " (%s)", name ? name : actx->external.direct_reference);
}
diff --git a/epan/dissectors/packet-p22.c b/epan/dissectors/packet-p22.c
index f0670d3f0e..2fb3a0aa24 100644
--- a/epan/dissectors/packet-p22.c
+++ b/epan/dissectors/packet-p22.c
@@ -1035,7 +1035,7 @@ dissect_p22_T_type(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_,
offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &actx->external.direct_reference);
- name = oid_resolved_from_string(actx->external.direct_reference);
+ name = oid_resolved_from_string(wmem_packet_scope(), actx->external.direct_reference);
proto_item_append_text(tree, " (%s)", name ? name : actx->external.direct_reference);
diff --git a/epan/dissectors/packet-per.c b/epan/dissectors/packet-per.c
index 3860305f19..ca14c4a6a0 100644
--- a/epan/dissectors/packet-per.c
+++ b/epan/dissectors/packet-per.c
@@ -964,7 +964,7 @@ dissect_per_any_oid(tvbuff_t *tvb, guint32 offset, asn1_ctx_t *actx, proto_tree
if ((is_absolute && hfi->type == FT_OID) || (is_absolute && hfi->type == FT_REL_OID)) {
actx->created_item = proto_tree_add_item(tree, hf_index, val_tvb, 0, length, ENC_BIG_ENDIAN);
} else if (IS_FT_STRING(hfi->type)) {
- str = oid_encoded2string(tvb_get_ptr(val_tvb, 0, length), length);
+ str = oid_encoded2string(wmem_packet_scope(), tvb_get_ptr(val_tvb, 0, length), length);
actx->created_item = proto_tree_add_string(tree, hf_index, val_tvb, 0, length, str);
} else {
DISSECTOR_ASSERT_NOT_REACHED();
@@ -1000,7 +1000,7 @@ dissect_per_any_oid_str(tvbuff_t *tvb, guint32 offset, asn1_ctx_t *actx, proto_t
if (value_stringx) {
if (value_tvb && (length = tvb_captured_length(value_tvb))) {
- *value_stringx = oid_encoded2string(tvb_get_ptr(value_tvb, 0, length), length);
+ *value_stringx = oid_encoded2string(wmem_packet_scope(), tvb_get_ptr(value_tvb, 0, length), length);
} else {
*value_stringx = "";
}
diff --git a/epan/dissectors/packet-pkcs12.c b/epan/dissectors/packet-pkcs12.c
index be24d87201..1bded351d6 100644
--- a/epan/dissectors/packet-pkcs12.c
+++ b/epan/dissectors/packet-pkcs12.c
@@ -178,7 +178,7 @@ static void append_oid(proto_tree *tree, const char *oid)
{
const char *name = NULL;
- name = oid_resolved_from_string(oid);
+ name = oid_resolved_from_string(wmem_packet_scope(), oid);
proto_item_append_text(tree, " (%s)", name ? name : oid);
}
@@ -461,7 +461,7 @@ int PBE_decrypt_data(const char *object_identifier_id_param, tvbuff_t *encrypted
tvb_set_free_cb(clear_tvb, g_free);
name = g_string_new("");
- oidname = oid_resolved_from_string(object_identifier_id_param);
+ oidname = oid_resolved_from_string(wmem_packet_scope(), object_identifier_id_param);
g_string_printf(name, "Decrypted %s", oidname ? oidname : object_identifier_id_param);
/* add it as a new source */
diff --git a/epan/dissectors/packet-pres.c b/epan/dissectors/packet-pres.c
index 7e914841fc..a089d0bebb 100644
--- a/epan/dissectors/packet-pres.c
+++ b/epan/dissectors/packet-pres.c
@@ -445,7 +445,7 @@ dissect_pres_Presentation_context_identifier(gboolean implicit_tag _U_, tvbuff_t
oid = find_oid_by_pres_ctx_id(actx->pinfo, presentation_context_identifier);
- if(oid && (name = oid_resolved_from_string(oid))) {
+ if(oid && (name = oid_resolved_from_string(wmem_packet_scope(), oid))) {
proto_item_append_text(actx->created_item, " (%s)", name);
}
diff --git a/epan/dissectors/packet-snmp.c b/epan/dissectors/packet-snmp.c
index bc5373272e..7499c575ea 100644
--- a/epan/dissectors/packet-snmp.c
+++ b/epan/dissectors/packet-snmp.c
@@ -709,21 +709,21 @@ dissect_snmp_VarBind(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,
/* fetch ObjectName and its relative oid_info */
oid_bytes = (guint8*)tvb_memdup(wmem_packet_scope(), tvb, name_offset, name_len);
- oid_info = oid_get_from_encoded(oid_bytes, name_len, &subids, &oid_matched, &oid_left);
+ oid_info = oid_get_from_encoded(wmem_packet_scope(), oid_bytes, name_len, &subids, &oid_matched, &oid_left);
add_oid_debug_subtree(oid_info,pt_name);
if (!subids) {
proto_item* pi;
- repr = oid_encoded2string(oid_bytes, name_len);
+ repr = oid_encoded2string(wmem_packet_scope(), oid_bytes, name_len);
pt = proto_tree_add_subtree_format(pt_name,tvb, 0, 0, ett_decoding_error, &pi, "invalid oid: %s", repr);
expert_add_info_format(actx->pinfo, pi, &ei_snmp_invalid_oid, "invalid oid: %s", repr);
return dissect_unknown_ber(actx->pinfo, tvb, name_offset, pt);
}
if (oid_matched+oid_left) {
- oid_string = oid_subid2string(subids,oid_matched+oid_left);
+ oid_string = oid_subid2string(wmem_packet_scope(), subids,oid_matched+oid_left);
}
if (ber_class == BER_CLASS_CON) {
@@ -854,7 +854,7 @@ show_oid_index:
goto indexing_done;
}
- suboid_buf_len = oid_subid2encoded(suboid_len, suboid, &suboid_buf);
+ suboid_buf_len = oid_subid2encoded(wmem_packet_scope(), suboid_len, suboid, &suboid_buf);
DISSECTOR_ASSERT(suboid_buf_len);
@@ -1122,13 +1122,13 @@ set_label:
if (oid_info && oid_info->name) {
if (oid_left >= 1) {
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));
+ oid_subid2string(wmem_packet_scope(), &(subids[oid_matched]),oid_left),
+ oid_subid2string(wmem_packet_scope(), subids,oid_matched+oid_left));
info_oid = wmem_strdup_printf(wmem_packet_scope(), "%s.%s", oid_info->name,
- oid_subid2string(&(subids[oid_matched]),oid_left));
+ oid_subid2string(wmem_packet_scope(), &(subids[oid_matched]),oid_left));
} else {
repr = wmem_strdup_printf(wmem_packet_scope(), "%s (%s)", oid_info->name,
- oid_subid2string(subids,oid_matched));
+ oid_subid2string(wmem_packet_scope(), subids,oid_matched));
info_oid = oid_info->name;
}
} else if (oid_string) {
@@ -1977,7 +1977,7 @@ dissect_snmp_EnterpriseOID(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int off
if (display_oid && enterprise_oid) {
- name = oid_resolved_from_string(enterprise_oid);
+ name = oid_resolved_from_string(wmem_packet_scope(), enterprise_oid);
if (name) {
col_append_fstr (actx->pinfo->cinfo, COL_INFO, " %s", name);
}
diff --git a/epan/dissectors/packet-x509af.c b/epan/dissectors/packet-x509af.c
index 5d664ad0ae..e3cabe6295 100644
--- a/epan/dissectors/packet-x509af.c
+++ b/epan/dissectors/packet-x509af.c
@@ -218,7 +218,7 @@ dissect_x509af_T_algorithmId(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int o
algorithm_id = actx->external.direct_reference;
if(actx->external.direct_reference) {
- name = oid_resolved_from_string(actx->external.direct_reference);
+ name = oid_resolved_from_string(wmem_packet_scope(), actx->external.direct_reference);
proto_item_append_text(tree, " (%s)", name ? name : actx->external.direct_reference);
}
@@ -376,7 +376,7 @@ dissect_x509af_T_extnId(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset
if(actx->external.direct_reference) {
- name = oid_resolved_from_string(actx->external.direct_reference);
+ name = oid_resolved_from_string(wmem_packet_scope(), actx->external.direct_reference);
proto_item_append_text(tree, " (%s)", name ? name : actx->external.direct_reference);
}
diff --git a/epan/dissectors/packet-x509if.c b/epan/dissectors/packet-x509if.c
index c4e727342c..1d51148173 100644
--- a/epan/dissectors/packet-x509if.c
+++ b/epan/dissectors/packet-x509if.c
@@ -728,7 +728,7 @@ dissect_x509if_T_type_02(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offse
if(actx->external.direct_reference) {
/* see if we can find a nice name */
- name = oid_resolved_from_string(actx->external.direct_reference);
+ name = oid_resolved_from_string(wmem_packet_scope(), actx->external.direct_reference);
if(!name) name = actx->external.direct_reference;
if(last_rdn) { /* append it to the RDN */
@@ -801,7 +801,7 @@ dissect_x509if_T_atadv_value(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int o
last_ava = (char *)wmem_alloc(wmem_packet_scope(), MAX_AVA_STR_LEN);
}
- if(!(name = oid_resolved_from_string(actx->external.direct_reference)))
+ if(!(name = oid_resolved_from_string(wmem_packet_scope(), actx->external.direct_reference)))
name = actx->external.direct_reference;
g_snprintf(last_ava, MAX_AVA_STR_LEN, "%s %s %s", name, fmt, value);
diff --git a/epan/ftypes/ftype-bytes.c b/epan/ftypes/ftype-bytes.c
index fc42f0c9f0..0669071ed3 100644
--- a/epan/ftypes/ftype-bytes.c
+++ b/epan/ftypes/ftype-bytes.c
@@ -97,7 +97,7 @@ oid_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_, int field_display _U_)
static void
oid_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, int field_display _U_, char *buf)
{
- const char* oid_str = oid_encoded2string(fv->value.bytes->data,fv->value.bytes->len);
+ char* oid_str = oid_encoded2string(NULL, fv->value.bytes->data,fv->value.bytes->len);
/*
* XXX:
* I'm assuming that oid_repr_len is going to be called before to set buf's size.
@@ -105,7 +105,8 @@ oid_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, int field_display _U_, char *buf)
* I guess that is why this callback is not passed a length.
* -- lego
*/
- strncpy(buf,oid_str,OID_REPR_LEN(fv));
+ g_strlcpy(buf,oid_str,OID_REPR_LEN(fv));
+ wmem_free(NULL, oid_str);
}
static int
@@ -117,7 +118,7 @@ rel_oid_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_, int field_display _U_)
static void
rel_oid_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, int field_display _U_, char *buf)
{
- const char* oid_str = rel_oid_encoded2string(fv->value.bytes->data,fv->value.bytes->len);
+ char* oid_str = rel_oid_encoded2string(NULL, fv->value.bytes->data,fv->value.bytes->len);
/*
* XXX:
* I'm assuming that oid_repr_len is going to be called before to set buf's size.
@@ -126,7 +127,8 @@ rel_oid_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, int field_display _U_, char *b
* -- lego
*/
*buf++ = '.';
- strncpy(buf,oid_str,REL_OID_REPR_LEN(fv));
+ g_strlcpy(buf,oid_str,REL_OID_REPR_LEN(fv));
+ wmem_free(NULL, oid_str);
}
static void
diff --git a/epan/oids.c b/epan/oids.c
index 2437a46a00..463fe692b9 100644
--- a/epan/oids.c
+++ b/epan/oids.c
@@ -30,7 +30,6 @@
#include <wsutil/report_err.h>
-#include "emem.h"
#include "wmem/wmem.h"
#include "uat.h"
#include "prefs.h"
@@ -171,8 +170,10 @@ static oid_info_t* add_oid(const char* name, oid_kind_t kind, const oid_value_ty
void oid_add(const char* name, guint oid_len, guint32 *subids) {
g_assert(subids && *subids <= 2);
if (oid_len) {
- D(3,("\tOid (from subids): %s %s ",name?name:"NULL", oid_subid2string(subids,oid_len)));
+ gchar* sub = oid_subid2string(NULL, subids,oid_len);
+ D(3,("\tOid (from subids): %s %s ",name?name:"NULL", sub));
add_oid(name,OID_KIND_UNKNOWN,NULL,NULL,oid_len,subids);
+ wmem_free(NULL, sub);
} else {
D(1,("Failed to add Oid: %s (from subids)",name?name:"NULL"));
}
@@ -183,8 +184,10 @@ void oid_add_from_string(const char* name, const gchar *oid_str) {
guint oid_len = oid_string2subid(NULL, oid_str, &subids);
if (oid_len) {
- D(3,("\tOid (from string): %s %s ",name?name:"NULL", oid_subid2string(subids,oid_len)));
+ gchar* sub = oid_subid2string(NULL, subids,oid_len);
+ D(3,("\tOid (from string): %s %s ",name?name:"NULL", sub));
add_oid(name,OID_KIND_UNKNOWN,NULL,NULL,oid_len,subids);
+ wmem_free(NULL, sub);
} else {
D(1,("Failed to add Oid: %s %s ",name?name:"NULL", oid_str?oid_str:NULL));
}
@@ -192,17 +195,20 @@ void oid_add_from_string(const char* name, const gchar *oid_str) {
}
extern void oid_add_from_encoded(const char* name, const guint8 *oid, gint oid_len) {
- guint32* subids;
- guint subids_len = oid_encoded2subid(oid, oid_len, &subids);
+ guint32* subids = NULL;
+ guint subids_len = oid_encoded2subid(NULL, oid, oid_len, &subids);
if (subids_len) {
- D(3,("\tOid (from encoded): %s %s ",name, oid_subid2string(subids,subids_len)));
+ gchar* sub = oid_subid2string(NULL, subids,subids_len);
+ D(3,("\tOid (from encoded): %s %s ",name, sub));
add_oid(name,OID_KIND_UNKNOWN,NULL,NULL,subids_len,subids);
+ wmem_free(NULL, sub);
} else {
gchar* bytestr = (gchar*)bytestring_to_str(NULL, oid, oid_len, ':');
D(1,("Failed to add Oid: %s [%d]%s ",name?name:"NULL", oid_len, bytestr));
wmem_free(NULL, bytestr);
}
+ wmem_free(NULL, subids);
}
#ifdef HAVE_LIBSMI
@@ -611,6 +617,7 @@ static void register_mibs(void) {
const oid_value_type_t* typedata = get_typedata(smiType);
oid_key_t* key;
oid_kind_t kind = smikind(smiNode,&key);
+ char *sub;
char *oid = smiRenderOID(smiNode->oidlen, smiNode->oid, SMI_RENDER_QUALIFIED);
oid_info_t* oid_data = add_oid(oid,
kind,
@@ -620,23 +627,25 @@ static void register_mibs(void) {
smiNode->oid);
smi_free (oid);
+ sub = oid_subid2string(NULL, smiNode->oid, smiNode->oidlen);
D(4,("\t\tNode: kind=%d oid=%s name=%s ",
- oid_data->kind, oid_subid2string(smiNode->oid, smiNode->oidlen), oid_data->name ));
+ oid_data->kind, sub, oid_data->name));
+ wmem_free(NULL, sub);
if ( typedata && oid_data->value_hfid == -2 ) {
SmiNamedNumber* smiEnum;
hf_register_info hf;
- hf.p_id = &(oid_data->value_hfid);
- hf.hfinfo.name = oid_data->name;
- hf.hfinfo.abbrev = alnumerize(oid_data->name);
- hf.hfinfo.type = typedata->ft_type;
- hf.hfinfo.display = typedata->display;
- hf.hfinfo.strings = NULL;
- hf.hfinfo.bitmask = 0;
- hf.hfinfo.blurb = smiRenderOID(smiNode->oidlen, smiNode->oid, SMI_RENDER_ALL);
- /* HFILL */
- HFILL_INIT(hf);
+ hf.p_id = &(oid_data->value_hfid);
+ hf.hfinfo.name = oid_data->name;
+ hf.hfinfo.abbrev = alnumerize(oid_data->name);
+ hf.hfinfo.type = typedata->ft_type;
+ hf.hfinfo.display = typedata->display;
+ hf.hfinfo.strings = NULL;
+ hf.hfinfo.bitmask = 0;
+ hf.hfinfo.blurb = smiRenderOID(smiNode->oidlen, smiNode->oid, SMI_RENDER_ALL);
+ /* HFILL */
+ HFILL_INIT(hf);
/* Don't allow duplicate blurb/name */
if (strcmp(hf.hfinfo.blurb, hf.hfinfo.name) == 0) {
@@ -651,9 +660,9 @@ static void register_mibs(void) {
for(;smiEnum; smiEnum = smiGetNextNamedNumber(smiEnum)) {
if (smiEnum->name) {
- value_string val;
- val.value = (guint32)smiEnum->value.value.integer32;
- val.strptr = g_strdup(smiEnum->name);
+ value_string val;
+ val.value = (guint32)smiEnum->value.value.integer32;
+ val.strptr = g_strdup(smiEnum->name);
g_array_append_val(vals,val);
}
}
@@ -710,8 +719,8 @@ static void register_mibs(void) {
hf.hfinfo.strings = NULL;
hf.hfinfo.bitmask = 0;
hf.hfinfo.blurb = NULL;
- /* HFILL */
- HFILL_INIT(hf);
+ /* HFILL */
+ HFILL_INIT(hf);
D(5,("\t\t\tIndex: name=%s subids=%d key_type=%d",
key->name, key->num_subids, key->key_type ));
@@ -847,16 +856,16 @@ void oids_cleanup(void) {
#endif
}
-const char* oid_subid2string(guint32* subids, guint len) {
- return rel_oid_subid2string(subids, len, TRUE);
+char* oid_subid2string(wmem_allocator_t *scope, guint32* subids, guint len) {
+ return rel_oid_subid2string(scope, subids, len, TRUE);
}
-const char* rel_oid_subid2string(guint32* subids, guint len, gboolean is_absolute) {
+char* rel_oid_subid2string(wmem_allocator_t *scope, guint32* subids, guint len, gboolean is_absolute) {
char *s, *w;
if(!subids || len == 0)
- return "*** Empty OID ***";
+ return wmem_strdup(scope, "*** Empty OID ***");
- s = (char *)ep_alloc0(((len)*11)+2);
+ s = (char *)wmem_alloc0(scope, ((len)*11)+2);
w = s;
if (!is_absolute)
@@ -882,7 +891,7 @@ static guint check_num_oid(const char* str) {
do {
D(9,("\tcheck_num_oid: '%c' %d",*r,n));
switch(*r) {
- case '.': case '\0':
+ case '.': case '\0':
n++;
if (c == '.') return 0;
break;
@@ -945,10 +954,10 @@ guint oid_string2subid(wmem_allocator_t *scope, const char* str, guint32** subid
}
-guint oid_encoded2subid(const guint8 *oid_bytes, gint oid_len, guint32** subids_p) {
- return oid_encoded2subid_sub(oid_bytes, oid_len, subids_p, TRUE);
+guint oid_encoded2subid(wmem_allocator_t *scope, const guint8 *oid_bytes, gint oid_len, guint32** subids_p) {
+ return oid_encoded2subid_sub(scope, oid_bytes, oid_len, subids_p, TRUE);
}
-guint oid_encoded2subid_sub(const guint8 *oid_bytes, gint oid_len, guint32** subids_p,
+guint oid_encoded2subid_sub(wmem_allocator_t *scope, const guint8 *oid_bytes, gint oid_len, guint32** subids_p,
gboolean is_first) {
gint i;
guint n = is_first ? 1 : 0;
@@ -962,7 +971,7 @@ guint oid_encoded2subid_sub(const guint8 *oid_bytes, gint oid_len, guint32** sub
for (i=0; i<oid_len; i++) { if (! (oid_bytes[i] & 0x80 )) n++; }
- *subids_p = subids = (guint32 *)ep_alloc(sizeof(guint32)*n);
+ *subids_p = subids = (guint32 *)wmem_alloc(scope, sizeof(guint32)*n);
subid_overflow = subids+n;
/* If n is 0 or 1 (depending on how it was initialized) then we found
@@ -1038,8 +1047,8 @@ done:
}
-oid_info_t* oid_get_from_encoded(const guint8 *bytes, gint byteslen, guint32** subids_p, guint* matched_p, guint* left_p) {
- guint subids_len = oid_encoded2subid(bytes, byteslen, subids_p);
+oid_info_t* oid_get_from_encoded(wmem_allocator_t *scope, const guint8 *bytes, gint byteslen, guint32** subids_p, guint* matched_p, guint* left_p) {
+ guint subids_len = oid_encoded2subid(scope, bytes, byteslen, subids_p);
return oid_get(subids_len, *subids_p, matched_p, left_p);
}
@@ -1048,22 +1057,28 @@ oid_info_t* oid_get_from_string(wmem_allocator_t *scope, const gchar *oid_str, g
return oid_get(subids_len, *subids_p, matched, left);
}
-const gchar *oid_resolved_from_encoded(const guint8 *oid, gint oid_len) {
- guint32 *subid_oid;
- guint subid_oid_length = oid_encoded2subid(oid, oid_len, &subid_oid);
+gchar *oid_resolved_from_encoded(wmem_allocator_t *scope, const guint8 *oid, gint oid_len) {
+ guint32 *subid_oid = NULL;
+ gchar * ret;
+ guint subid_oid_length = oid_encoded2subid(NULL, oid, oid_len, &subid_oid);
- return oid_resolved(subid_oid_length, subid_oid);
+ ret = oid_resolved(scope, subid_oid_length, subid_oid);
+ wmem_free(NULL, subid_oid);
+ return ret;
}
-const gchar *rel_oid_resolved_from_encoded(const guint8 *oid, gint oid_len) {
- guint32 *subid_oid;
- guint subid_oid_length = oid_encoded2subid_sub(oid, oid_len, &subid_oid, FALSE);
+gchar *rel_oid_resolved_from_encoded(wmem_allocator_t *scope, const guint8 *oid, gint oid_len) {
+ guint32 *subid_oid = NULL;
+ gchar* ret;
+ guint subid_oid_length = oid_encoded2subid_sub(NULL, oid, oid_len, &subid_oid, FALSE);
- return rel_oid_subid2string(subid_oid, subid_oid_length, FALSE);
+ ret = rel_oid_subid2string(scope, subid_oid, subid_oid_length, FALSE);
+ wmem_free(NULL, subid_oid);
+ return ret;
}
-guint oid_subid2encoded(guint subids_len, guint32* subids, guint8** bytes_p) {
+guint oid_subid2encoded(wmem_allocator_t *scope, guint subids_len, guint32* subids, guint8** bytes_p) {
guint bytelen = 0;
guint i;
guint32 subid;
@@ -1089,7 +1104,7 @@ guint oid_subid2encoded(guint subids_len, guint32* subids, guint8** bytes_p) {
}
}
- *bytes_p = b = (guint8 *)ep_alloc(bytelen);
+ *bytes_p = b = (guint8 *)wmem_alloc(scope, bytelen);
for (subid=subids[0] * 40, i = 1; i<subids_len; i++, subid=0) {
guint len;
@@ -1114,35 +1129,43 @@ guint oid_subid2encoded(guint subids_len, guint32* subids, guint8** bytes_p) {
return bytelen;
}
-const gchar* oid_encoded2string(const guint8* encoded, guint len) {
- guint32* subids;
- guint subids_len = oid_encoded2subid(encoded, len, &subids);
+gchar* oid_encoded2string(wmem_allocator_t *scope, const guint8* encoded, guint len) {
+ guint32* subids = NULL;
+ gchar* ret;
+ guint subids_len = oid_encoded2subid(NULL, encoded, len, &subids);
if (subids_len) {
- return oid_subid2string(subids,subids_len);
+ ret = oid_subid2string(scope, subids,subids_len);
} else {
- return "";
+ ret = wmem_strdup(scope, "");
}
+
+ wmem_free(NULL, subids);
+ return ret;
}
-const gchar* rel_oid_encoded2string(const guint8* encoded, guint len) {
- guint32* subids;
- guint subids_len = oid_encoded2subid_sub(encoded, len, &subids, FALSE);
+gchar* rel_oid_encoded2string(wmem_allocator_t *scope, const guint8* encoded, guint len) {
+ guint32* subids = NULL;
+ gchar* ret;
+ guint subids_len = oid_encoded2subid_sub(NULL, encoded, len, &subids, FALSE);
if (subids_len) {
- return rel_oid_subid2string(subids,subids_len, FALSE);
+ ret = rel_oid_subid2string(scope, subids,subids_len, FALSE);
} else {
- return "";
+ ret = wmem_strdup(scope, "");
}
+
+ wmem_free(NULL, subids);
+ return ret;
}
-guint oid_string2encoded(const char *oid_str, guint8 **bytes) {
+guint oid_string2encoded(wmem_allocator_t *scope, const char *oid_str, guint8 **bytes) {
guint32* subids;
guint32 subids_len;
guint byteslen;
if ( (subids_len = oid_string2subid(NULL, oid_str, &subids)) &&
- (byteslen = oid_subid2encoded(subids_len, subids, bytes)) ) {
+ (byteslen = oid_subid2encoded(scope, subids_len, subids, bytes)) ) {
wmem_free(NULL, subids);
return byteslen;
}
@@ -1150,65 +1173,71 @@ guint oid_string2encoded(const char *oid_str, guint8 **bytes) {
return 0;
}
-const gchar *oid_resolved_from_string(const gchar *oid_str) {
+gchar *oid_resolved_from_string(wmem_allocator_t *scope, const gchar *oid_str) {
guint32 *subid_oid;
guint subid_oid_length;
- const gchar *resolved;
+ gchar *resolved;
subid_oid_length = oid_string2subid(NULL, oid_str, &subid_oid);
- resolved = oid_resolved(subid_oid_length, subid_oid);
+ resolved = oid_resolved(scope, subid_oid_length, subid_oid);
wmem_free(NULL, subid_oid);
return resolved;
}
-const gchar *oid_resolved(guint32 num_subids, guint32* subids) {
+gchar *oid_resolved(wmem_allocator_t *scope, guint32 num_subids, guint32* subids) {
guint matched;
guint left;
oid_info_t* oid;
if(! (subids && *subids <= 2 ))
- return "*** Malformed OID ***";
+ return wmem_strdup(scope, "*** Malformed OID ***");
oid = oid_get(num_subids, subids, &matched, &left);
while (! oid->name ) {
if (!(oid = oid->parent)) {
- return oid_subid2string(subids,num_subids);
+ return oid_subid2string(scope, subids,num_subids);
}
left++;
matched--;
}
if (left) {
- return ep_strdup_printf("%s.%s",
- oid->name ? oid->name : oid_subid2string(subids,matched),
- oid_subid2string(&(subids[matched]),left));
+ gchar *ret,
+ *str1 = oid_subid2string(NULL, subids,matched),
+ *str2 = oid_subid2string(NULL, &(subids[matched]),left);
+
+ ret = wmem_strdup_printf(scope, "%s.%s", oid->name ? oid->name : str1, str2);
+ wmem_free(NULL, str1);
+ wmem_free(NULL, str2);
+ return ret;
} else {
- return oid->name ? oid->name : oid_subid2string(subids,matched);
+ return oid->name ? wmem_strdup(scope, oid->name) : oid_subid2string(scope, subids,matched);
}
}
-extern void oid_both(guint oid_len, guint32 *subids, const char** resolved_p, const char** numeric_p) {
- *resolved_p = oid_resolved(oid_len,subids);
- *numeric_p = oid_subid2string(subids,oid_len);
+extern void oid_both(wmem_allocator_t *scope, guint oid_len, guint32 *subids, gchar** resolved_p, gchar** numeric_p) {
+ *resolved_p = oid_resolved(scope, oid_len,subids);
+ *numeric_p = oid_subid2string(scope, subids,oid_len);
}
-extern void oid_both_from_encoded(const guint8 *oid, gint oid_len, const char** resolved_p, const char** numeric_p) {
- guint32* subids;
- guint subids_len = oid_encoded2subid(oid, oid_len, &subids);
- *resolved_p = oid_resolved(subids_len,subids);
- *numeric_p = oid_subid2string(subids,subids_len);
+extern void oid_both_from_encoded(wmem_allocator_t *scope, const guint8 *oid, gint oid_len, gchar** resolved_p, gchar** numeric_p) {
+ guint32* subids = NULL;
+ guint subids_len = oid_encoded2subid(NULL, oid, oid_len, &subids);
+ *resolved_p = oid_resolved(scope, subids_len,subids);
+ *numeric_p = oid_subid2string(scope, subids,subids_len);
+ wmem_free(NULL, subids);
}
-void oid_both_from_string(const gchar *oid_str, const char** resolved_p, const char** numeric_p) {
+void oid_both_from_string(wmem_allocator_t *scope, const gchar *oid_str, gchar** resolved_p, gchar** numeric_p) {
guint32 *subids;
guint subids_len;
subids_len = oid_string2subid(NULL, oid_str, &subids);
- *resolved_p = oid_resolved(subids_len,subids);
- *numeric_p = oid_subid2string(subids,subids_len);
+ *resolved_p = oid_resolved(scope, subids_len,subids);
+ *numeric_p = oid_subid2string(scope, subids,subids_len);
wmem_free(NULL, subids);
}
@@ -1245,7 +1274,7 @@ oid_get_default_mib_path(void) {
g_string_append(path_str, PATH_SEPARATOR);
}
g_string_append_printf(path_str, "%s", path);
- free (path);
+ smi_free(path);
#endif
for(i=0;i<num_smi_paths;i++) {
@@ -1263,18 +1292,19 @@ oid_get_default_mib_path(void) {
#ifdef DEBUG_OIDS
char* oid_test_a2b(guint32 num_subids, guint32* subids) {
- guint8* sub2enc;
- guint8* str2enc;
- guint32* enc2sub;
+ guint8* sub2enc = NULL;
+ guint8* str2enc = NULL;
+ guint32* enc2sub = NULL;
guint32* str2sub;
- const char* sub2str = oid_subid2string(subids, num_subids);
- guint sub2enc_len = oid_subid2encoded(num_subids, subids,&sub2enc);
- guint enc2sub_len = oid_encoded2subid(sub2enc, sub2enc_len, &enc2sub);
- const char* enc2str = oid_encoded2string(sub2enc, sub2enc_len);
- guint str2enc_len = oid_string2encoded(sub2str,&str2enc);
+ char* ret;
+ char* sub2str = oid_subid2string(NULL, subids, num_subids);
+ guint sub2enc_len = oid_subid2encoded(NULL, num_subids, subids,&sub2enc);
+ guint enc2sub_len = oid_encoded2subid(NULL, sub2enc, sub2enc_len, &enc2sub);
+ char* enc2str = oid_encoded2string(NULL, sub2enc, sub2enc_len);
+ guint str2enc_len = oid_string2encoded(NULL, sub2str,&str2enc);
guint str2sub_len = oid_string2subid(sub2str,&str2sub);
- return ep_strdup_printf(
+ ret = wmem_strdup_printf(wmem_packet_scope(),
"oid_subid2string=%s \n"
"oid_subid2encoded=[%d]%s \n"
"oid_encoded2subid=%s \n "
@@ -1283,11 +1313,18 @@ char* oid_test_a2b(guint32 num_subids, guint32* subids) {
"oid_string2subid=%s \n "
,sub2str
,sub2enc_len,bytestring_to_str(wmem_packet_scope(), sub2enc, sub2enc_len, ':')
- ,enc2sub ? oid_subid2string(enc2sub,enc2sub_len) : "-"
+ ,enc2sub ? oid_subid2string(wmem_packet_scope(), enc2sub,enc2sub_len) : "-"
,enc2str
,str2enc_len,bytestring_to_str(wmem_packet_scope(), str2enc, str2enc_len, ':')
- ,str2sub ? oid_subid2string(str2sub,str2sub_len) : "-"
+ ,str2sub ? oid_subid2string(wmem_packet_scope(), str2sub,str2sub_len) : "-"
);
+
+ wmem_free(NULL, sub2str);
+ wmem_free(NULL, enc2sub);
+ wmem_free(NULL, sub2enc);
+ wmem_free(NULL, str2enc);
+ wmem_free(NULL, enc2str);
+ return ret;
}
void add_oid_debug_subtree(oid_info_t* oid_info, proto_tree *tree) {
diff --git a/epan/oids.h b/epan/oids.h
index 4ddba2bd23..256af134af 100644
--- a/epan/oids.h
+++ b/epan/oids.h
@@ -136,34 +136,34 @@ WS_DLL_PUBLIC void oids_cleanup(void);
/* return length of encoded buffer */
WS_DLL_PUBLIC
-guint oid_subid2encoded(guint len, guint32* subids, guint8** encoded_p);
+guint oid_subid2encoded(wmem_allocator_t *scope, guint len, guint32* subids, guint8** encoded_p);
WS_DLL_PUBLIC
-guint oid_string2encoded(const gchar *oid_str, guint8** encoded_p);
+guint oid_string2encoded(wmem_allocator_t *scope, const gchar *oid_str, guint8** encoded_p);
/* return length of subid array */
WS_DLL_PUBLIC
-guint oid_encoded2subid(const guint8 *oid, gint len, guint32** subids_p);
+guint oid_encoded2subid(wmem_allocator_t *scope, const guint8 *oid, gint len, guint32** subids_p);
WS_DLL_PUBLIC
-guint oid_encoded2subid_sub(const guint8 *oid_bytes, gint oid_len, guint32** subids_pi,
+guint oid_encoded2subid_sub(wmem_allocator_t *scope, const guint8 *oid_bytes, gint oid_len, guint32** subids_pi,
gboolean is_first);
WS_DLL_PUBLIC
guint oid_string2subid(wmem_allocator_t *scope, const gchar *oid_str, guint32** subids_p);
-WS_DLL_PUBLIC const gchar* oid_encoded2string(const guint8* encoded, guint len);
-WS_DLL_PUBLIC const gchar* rel_oid_encoded2string(const guint8* encoded, guint len);
-WS_DLL_PUBLIC const gchar* oid_subid2string(guint32 *subids, guint len);
-WS_DLL_PUBLIC const gchar* rel_oid_subid2string(guint32 *subids, guint len, gboolean is_absolute);
+WS_DLL_PUBLIC gchar* oid_encoded2string(wmem_allocator_t *scope, const guint8* encoded, guint len);
+WS_DLL_PUBLIC gchar* rel_oid_encoded2string(wmem_allocator_t *scope, const guint8* encoded, guint len);
+WS_DLL_PUBLIC gchar* oid_subid2string(wmem_allocator_t *scope, guint32 *subids, guint len);
+WS_DLL_PUBLIC gchar* rel_oid_subid2string(wmem_allocator_t *scope, guint32 *subids, guint len, gboolean is_absolute);
/* these return a formated string as human readable as posible */
-WS_DLL_PUBLIC const gchar *oid_resolved(guint len, guint32 *subids);
-WS_DLL_PUBLIC const gchar *oid_resolved_from_encoded(const guint8 *oid, gint len);
-WS_DLL_PUBLIC const gchar *rel_oid_resolved_from_encoded(const guint8 *oid, gint len);
-WS_DLL_PUBLIC const gchar *oid_resolved_from_string(const gchar *oid_str);
+WS_DLL_PUBLIC gchar *oid_resolved(wmem_allocator_t *scope, guint len, guint32 *subids);
+WS_DLL_PUBLIC gchar *oid_resolved_from_encoded(wmem_allocator_t *scope, const guint8 *oid, gint len);
+WS_DLL_PUBLIC gchar *rel_oid_resolved_from_encoded(wmem_allocator_t *scope, const guint8 *oid, gint len);
+WS_DLL_PUBLIC gchar *oid_resolved_from_string(wmem_allocator_t *scope, const gchar *oid_str);
/* these yield two formated strings one resolved and one numeric */
-WS_DLL_PUBLIC void oid_both(guint oid_len, guint32 *subids, const char** resolved_p, const char** numeric_p);
-WS_DLL_PUBLIC void oid_both_from_encoded(const guint8 *oid, gint oid_len, const char** resolved_p, const char** numeric_p);
-WS_DLL_PUBLIC void oid_both_from_string(const gchar *oid_str, const char** resolved_p, const char** numeric_p);
+WS_DLL_PUBLIC void oid_both(wmem_allocator_t *scope, guint oid_len, guint32 *subids, gchar** resolved_p, gchar** numeric_p);
+WS_DLL_PUBLIC void oid_both_from_encoded(wmem_allocator_t *scope, const guint8 *oid, gint oid_len, gchar** resolved_p, gchar** numeric_p);
+WS_DLL_PUBLIC void oid_both_from_string(wmem_allocator_t *scope, const gchar *oid_str, gchar** resolved_p, gchar** numeric_p);
/*
* These return the info for the best match.
@@ -171,7 +171,7 @@ WS_DLL_PUBLIC void oid_both_from_string(const gchar *oid_str, const char** resol
* *left_p will be set to the number of remaining unresolved subids
*/
WS_DLL_PUBLIC oid_info_t* oid_get(guint oid_len, guint32 *subids, guint* matched_p, guint* left_p);
-WS_DLL_PUBLIC oid_info_t* oid_get_from_encoded(const guint8 *oid, gint oid_len, guint32 **subids, guint* matched, guint* left);
+WS_DLL_PUBLIC oid_info_t* oid_get_from_encoded(wmem_allocator_t *scope, const guint8 *oid, gint oid_len, guint32 **subids, guint* matched, guint* left);
WS_DLL_PUBLIC oid_info_t* oid_get_from_string(wmem_allocator_t *scope, const gchar *oid_str, guint32 **subids, guint* matched, guint* left);
/* these are used to add oids to the collection */
diff --git a/epan/oids_test.c b/epan/oids_test.c
index 3a0fa7d6e3..1df68cb83d 100644
--- a/epan/oids_test.c
+++ b/epan/oids_test.c
@@ -27,7 +27,6 @@
#include <string.h>
#include <glib.h>
-#include "emem.h"
#include "oids.h"
#include "wmem/wmem.h"
@@ -82,10 +81,11 @@ oids_test_2subids_encoded(void)
guint len;
guint i;
- len = oid_encoded2subid(ex1.encoded, ex1.encoded_len, &subids);
+ len = oid_encoded2subid(NULL, ex1.encoded, ex1.encoded_len, &subids);
g_assert(len == ex1.subids_len);
for (i=0; i < len; i++)
g_assert(subids[i] == ex1.subids[i]);
+ wmem_free(NULL, subids);
}
static void
@@ -95,10 +95,11 @@ oids_test_2subids_encoded_long(void)
guint len;
guint i;
- len = oid_encoded2subid(ex3.encoded, ex3.encoded_len, &subids);
+ len = oid_encoded2subid(NULL, ex3.encoded, ex3.encoded_len, &subids);
g_assert(len == ex3.subids_len);
for (i=0; i < len; i++)
g_assert(subids[i] == ex3.subids[i]);
+ wmem_free(NULL, subids);
}
static void
@@ -108,10 +109,11 @@ oids_test_2subids_encoded_absviasub(void)
guint len;
guint i;
- len = oid_encoded2subid_sub(ex1.encoded, ex1.encoded_len, &subids, TRUE);
+ len = oid_encoded2subid_sub(NULL, ex1.encoded, ex1.encoded_len, &subids, TRUE);
g_assert(len == ex1.subids_len);
for (i=0; i < len; i++)
g_assert(subids[i] == ex1.subids[i]);
+ wmem_free(NULL, subids);
}
static void
@@ -121,10 +123,11 @@ oids_test_2subids_encoded_relviasub(void)
guint len;
guint i;
- len = oid_encoded2subid_sub(ex2rel.encoded, ex2rel.encoded_len, &subids, FALSE);
+ len = oid_encoded2subid_sub(NULL, ex2rel.encoded, ex2rel.encoded_len, &subids, FALSE);
g_assert(len == ex2rel.subids_len);
for (i=0; i < len; i++)
g_assert(subids[i] == ex2rel.subids[i]);
+ wmem_free(NULL, subids);
}
static void
@@ -159,9 +162,10 @@ oids_test_2encoded_string_simple(void)
guint8 *encoded = NULL;
guint len;
- len = oid_string2encoded(ex1.string, &encoded);
+ len = oid_string2encoded(NULL, ex1.string, &encoded);
g_assert(len == ex1.encoded_len);
g_assert(0 == memcmp(encoded, ex1.encoded, len));
+ wmem_free(NULL, encoded);
}
static void
@@ -170,9 +174,10 @@ oids_test_2encoded_string_short(void)
guint8 *encoded = NULL;
guint len;
- len = oid_string2encoded(ex4.string, &encoded);
+ len = oid_string2encoded(NULL, ex4.string, &encoded);
g_assert(len == ex4.encoded_len);
g_assert(0 == memcmp(encoded, ex4.encoded, len));
+ wmem_free(NULL, encoded);
}
static void
@@ -181,9 +186,10 @@ oids_test_2encoded_string_long(void)
guint8 *encoded = NULL;
guint len;
- len = oid_string2encoded(ex3.string, &encoded);
+ len = oid_string2encoded(NULL, ex3.string, &encoded);
g_assert(len == ex3.encoded_len);
g_assert(0 == memcmp(encoded, ex3.encoded, len));
+ wmem_free(NULL, encoded);
}
static void
@@ -192,9 +198,10 @@ oids_test_2encoded_string_tooshort(void)
guint8 *encoded = NULL;
guint len;
- len = oid_string2encoded(ex5.string, &encoded);
+ len = oid_string2encoded(NULL, ex5.string, &encoded);
g_assert(len == ex5.encoded_len);
g_assert(0 == memcmp(encoded, ex5.encoded, len));
+ wmem_free(NULL, encoded);
}
static void
@@ -203,9 +210,10 @@ oids_test_2encoded_subids_simple(void)
guint8 *encoded = NULL;
guint len;
- len = oid_subid2encoded(ex1.subids_len, ex1.subids, &encoded);
+ len = oid_subid2encoded(NULL, ex1.subids_len, ex1.subids, &encoded);
g_assert(len == ex1.encoded_len);
g_assert(0 == memcmp(encoded, ex1.encoded, len));
+ wmem_free(NULL, encoded);
}
static void
@@ -214,9 +222,10 @@ oids_test_2encoded_subids_bad(void)
guint8 *encoded = NULL;
guint len;
- len = oid_subid2encoded(ex5.subids_len, ex5.subids, &encoded);
+ len = oid_subid2encoded(NULL, ex5.subids_len, ex5.subids, &encoded);
g_assert(len == ex5.encoded_len);
g_assert(0 == memcmp(encoded, ex5.encoded, len));
+ wmem_free(NULL, encoded);
}
/* OIDS TESTING FUNCTIONS (/oids/2string/) */
@@ -224,56 +233,62 @@ oids_test_2encoded_subids_bad(void)
static void
oids_test_2string_encoded(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = oid_encoded2string(ex3.encoded, ex3.encoded_len);
+ oid = oid_encoded2string(NULL, ex3.encoded, ex3.encoded_len);
g_assert_cmpstr(oid, ==, ex3.string);
+ wmem_free(NULL, oid);
}
static void
oids_test_2string_encoded_rel(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = rel_oid_encoded2string(ex6rel.encoded, ex3.encoded_len);
+ oid = rel_oid_encoded2string(NULL, ex6rel.encoded, ex3.encoded_len);
g_assert_cmpstr(oid, ==, ex6rel.string);
+ wmem_free(NULL, oid);
}
static void
oids_test_2string_subids_abs(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = oid_subid2string(ex1.subids, ex1.subids_len);
+ oid = oid_subid2string(NULL, ex1.subids, ex1.subids_len);
g_assert_cmpstr(oid, ==, ex1.string);
+ wmem_free(NULL, oid);
}
static void
oids_test_2string_subids_rel(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = rel_oid_subid2string(ex2rel.subids, ex2rel.subids_len, FALSE);
+ oid = rel_oid_subid2string(NULL, ex2rel.subids, ex2rel.subids_len, FALSE);
g_assert_cmpstr(oid, ==, ex2rel.string);
+ wmem_free(NULL, oid);
}
static void
oids_test_2string_subids_absviarel(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = rel_oid_subid2string(ex1.subids, ex1.subids_len, TRUE);
+ oid = rel_oid_subid2string(NULL, ex1.subids, ex1.subids_len, TRUE);
g_assert_cmpstr(oid, ==, ex1.string);
+ wmem_free(NULL, oid);
}
static void
oids_test_2string_subids_relsizes(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = rel_oid_subid2string(ex6rel.subids, ex6rel.subids_len, FALSE);
+ oid = rel_oid_subid2string(NULL, ex6rel.subids, ex6rel.subids_len, FALSE);
g_assert_cmpstr(oid, ==, ex6rel.string);
+ wmem_free(NULL, oid);
}
/* OIDS TESTING FUNCTIONS (/oids/2resolved/) */
@@ -281,37 +296,41 @@ oids_test_2string_subids_relsizes(void)
static void
oids_test_2resolved_subids(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = oid_resolved(ex1.subids_len, ex1.subids);
+ oid = oid_resolved(NULL, ex1.subids_len, ex1.subids);
g_assert_cmpstr(oid, ==, ex1.resolved);
+ wmem_free(NULL, oid);
}
static void
oids_test_2resolved_encoded(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = oid_resolved_from_encoded(ex1.encoded, ex1.encoded_len);
+ oid = oid_resolved_from_encoded(NULL, ex1.encoded, ex1.encoded_len);
g_assert_cmpstr(oid, ==, ex1.resolved);
+ wmem_free(NULL, oid);
}
static void
oids_test_2resolved_encoded_rel(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = rel_oid_resolved_from_encoded(ex2rel.encoded, ex2rel.encoded_len);
+ oid = rel_oid_resolved_from_encoded(NULL, ex2rel.encoded, ex2rel.encoded_len);
g_assert_cmpstr(oid, ==, ex2rel.string);
+ wmem_free(NULL, oid);
}
static void
oids_test_2resolved_string(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = oid_resolved_from_string(ex1.string);
+ oid = oid_resolved_from_string(NULL, ex1.string);
g_assert_cmpstr(oid, ==, ex1.resolved);
+ wmem_free(NULL, oid);
}
/* OIDS TESTING FUNCTIONS (/oids/2both/) */
@@ -319,34 +338,40 @@ oids_test_2resolved_string(void)
static void
oids_test_2both_subids(void)
{
- const gchar* resolved;
- const gchar* oid;
+ gchar* resolved;
+ gchar* oid;
- oid_both(ex1.subids_len, ex1.subids, &resolved, &oid);
+ oid_both(NULL, ex1.subids_len, ex1.subids, &resolved, &oid);
g_assert_cmpstr(resolved, ==, ex1.resolved);
g_assert_cmpstr(oid, ==, ex1.string);
+ wmem_free(NULL, resolved);
+ wmem_free(NULL, oid);
}
static void
oids_test_2both_encoded(void)
{
- const gchar* resolved;
- const gchar* oid;
+ gchar* resolved;
+ gchar* oid;
- oid_both_from_encoded(ex1.encoded, ex1.encoded_len, &resolved, &oid);
+ oid_both_from_encoded(NULL, ex1.encoded, ex1.encoded_len, &resolved, &oid);
g_assert_cmpstr(resolved, ==, ex1.resolved);
g_assert_cmpstr(oid, ==, ex1.string);
+ wmem_free(NULL, resolved);
+ wmem_free(NULL, oid);
}
static void
oids_test_2both_string(void)
{
- const gchar* resolved;
- const gchar* oid;
+ gchar* resolved;
+ gchar* oid;
- oid_both_from_string(ex1.string, &resolved, &oid);
+ oid_both_from_string(NULL, ex1.string, &resolved, &oid);
g_assert_cmpstr(resolved, ==, ex1.resolved);
g_assert_cmpstr(oid, ==, ex1.string);
+ wmem_free(NULL, resolved);
+ wmem_free(NULL, oid);
}
/* OIDS TESTING FUNCTIONS (/oids/2both/) */
@@ -370,11 +395,11 @@ oids_test_2struct_encoded(void)
{
guint matched;
guint left;
- guint32 *subids;
+ guint32 *subids = NULL;;
oid_info_t *st;
guint len, i;
- st = oid_get_from_encoded(ex1.encoded, ex1.encoded_len, &subids, &matched, &left);
+ st = oid_get_from_encoded(NULL, ex1.encoded, ex1.encoded_len, &subids, &matched, &left);
g_assert(matched == 1);
g_assert(left == ex1.subids_len - 1);
g_assert(st != NULL);
@@ -383,6 +408,7 @@ oids_test_2struct_encoded(void)
g_assert(len == ex1.subids_len);
for (i=0; i < len; i++)
g_assert(subids[i] == ex1.subids[i]);
+ wmem_free(NULL, subids);
}
static void
@@ -408,31 +434,34 @@ oids_test_2struct_string(void)
static void
oids_test_add_subids(void)
{
- const gchar* oid;
+ gchar* oid;
oid_add(ex7.resolved, ex7.subids_len, ex7.subids);
- oid = oid_resolved(ex7.subids_len, ex7.subids);
+ oid = oid_resolved(NULL, ex7.subids_len, ex7.subids);
g_assert_cmpstr(oid, ==, ex7.resolved);
+ wmem_free(NULL, oid);
}
static void
oids_test_add_encoded(void)
{
- const gchar* oid;
+ gchar* oid;
oid_add_from_encoded(ex7.resolved, ex7.encoded, ex7.encoded_len);
- oid = oid_resolved(ex7.subids_len, ex7.subids);
+ oid = oid_resolved(NULL, ex7.subids_len, ex7.subids);
g_assert_cmpstr(oid, ==, ex7.resolved);
+ wmem_free(NULL, oid);
}
static void
oids_test_add_string(void)
{
- const gchar* oid;
+ gchar* oid;
oid_add_from_string(ex7.resolved, ex7.string);
- oid = oid_resolved(ex7.subids_len, ex7.subids);
+ oid = oid_resolved(NULL, ex7.subids_len, ex7.subids);
g_assert_cmpstr(oid, ==, ex7.resolved);
+ wmem_free(NULL, oid);
}
int
@@ -488,7 +517,6 @@ main(int argc, char **argv)
g_test_add_func("/oids/add/encoded", oids_test_add_encoded);
g_test_add_func("/oids/add/string", oids_test_add_string);
- emem_init();
wmem_init();
test_scope = wmem_allocator_new(WMEM_ALLOCATOR_STRICT);
oids_init();
@@ -496,10 +524,7 @@ main(int argc, char **argv)
oids_cleanup();
wmem_destroy_allocator(test_scope);
wmem_cleanup();
- /*
- * This might have been a good place for a call to ep_free_all() but that is not part of the
- * public interface for emem.h
- */
+
return result;
}
diff --git a/epan/proto.c b/epan/proto.c
index 3849af4365..9e019efd60 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -4419,24 +4419,24 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
case FT_REL_OID:
bytes = (guint8 *)fvalue_get(&finfo->value);
- offset_r += protoo_strlcpy(result+offset_r,
- rel_oid_resolved_from_encoded(bytes,
- fvalue_length(&finfo->value)),
- size-offset_r);
- offset_e += protoo_strlcpy(expr+offset_e,
- rel_oid_encoded2string(bytes, fvalue_length(&finfo->value)),
- size-offset_e);
+ str = rel_oid_resolved_from_encoded(NULL, bytes, fvalue_length(&finfo->value));
+ offset_r += protoo_strlcpy(result+offset_r, str, size-offset_r);
+ wmem_free(NULL, str);
+
+ str = rel_oid_encoded2string(NULL, bytes, fvalue_length(&finfo->value));
+ offset_e += protoo_strlcpy(expr+offset_e, str, size-offset_e);
+ wmem_free(NULL, str);
break;
case FT_OID:
bytes = (guint8 *)fvalue_get(&finfo->value);
- offset_r += protoo_strlcpy(result+offset_r,
- oid_resolved_from_encoded(bytes,
- fvalue_length(&finfo->value)),
- size-offset_r);
- offset_e += protoo_strlcpy(expr+offset_e,
- oid_encoded2string(bytes, fvalue_length(&finfo->value)),
- size-offset_e);
+ str = oid_resolved_from_encoded(NULL, bytes, fvalue_length(&finfo->value));
+ offset_r += protoo_strlcpy(result+offset_r, str, size-offset_r);
+ wmem_free(NULL, str);
+
+ str = oid_encoded2string(NULL, bytes, fvalue_length(&finfo->value));
+ offset_e += protoo_strlcpy(expr+offset_e, str, size-offset_e);
+ wmem_free(NULL, str);
break;
case FT_SYSTEM_ID:
@@ -5990,7 +5990,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
ipv4_addr *ipv4;
e_guid_t *guid;
guint32 n_addr; /* network-order IPv4 address */
- const gchar *name;
+ gchar *name;
address addr;
char *addr_str;
char *tmp;
@@ -6209,26 +6209,28 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
case FT_OID:
bytes = (guint8 *)fvalue_get(&fi->value);
- name = oid_resolved_from_encoded(bytes, fvalue_length(&fi->value));
+ name = oid_resolved_from_encoded(NULL, bytes, fvalue_length(&fi->value));
+ tmp = oid_encoded2string(NULL, bytes, fvalue_length(&fi->value));
if (name) {
- label_fill_descr(label_str, 0, hfinfo,
- oid_encoded2string(bytes, fvalue_length(&fi->value)), name);
+ label_fill_descr(label_str, 0, hfinfo, tmp, name);
+ wmem_free(NULL, name);
} else {
- label_fill(label_str, 0, hfinfo,
- oid_encoded2string(bytes, fvalue_length(&fi->value)));
+ label_fill(label_str, 0, hfinfo, tmp);
}
+ wmem_free(NULL, tmp);
break;
case FT_REL_OID:
bytes = (guint8 *)fvalue_get(&fi->value);
- name = rel_oid_resolved_from_encoded(bytes, fvalue_length(&fi->value));
+ name = rel_oid_resolved_from_encoded(NULL, bytes, fvalue_length(&fi->value));
+ tmp = rel_oid_encoded2string(NULL, bytes, fvalue_length(&fi->value));
if (name) {
- label_fill_descr(label_str, 0, hfinfo,
- rel_oid_encoded2string(bytes, fvalue_length(&fi->value)), name);
+ label_fill_descr(label_str, 0, hfinfo, tmp, name);
+ wmem_free(NULL, name);
} else {
- label_fill(label_str, 0, hfinfo,
- rel_oid_encoded2string(bytes, fvalue_length(&fi->value)));
+ label_fill(label_str, 0, hfinfo, tmp);
}
+ wmem_free(NULL, tmp);
break;
case FT_SYSTEM_ID:
@@ -6241,7 +6243,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
case FT_EUI64:
integer64 = fvalue_get_integer64(&fi->value);
addr_str = eui64_to_str(NULL, integer64);
- tmp = (char*)eui64_to_display(NULL, integer64);
+ tmp = (char*)eui64_to_display(NULL, integer64);
label_fill_descr(label_str, 0, hfinfo, tmp, addr_str);
wmem_free(NULL, tmp);
wmem_free(NULL, addr_str);