aboutsummaryrefslogtreecommitdiffstats
path: root/asn1
diff options
context:
space:
mode:
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2011-04-12 20:39:48 +0000
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2011-04-12 20:39:48 +0000
commitc491c382637b3d6155f443e3450b61b5557d43b4 (patch)
tree5635709d1446638e6c63e1971bcf4bcc34761c92 /asn1
parenteeb8eee7a77eac77957e6557c5c9a2c5c8c57595 (diff)
Add x509if_frame_end() which is passed to register_frame_end_routine()
and which resets our global variables. Remove a boolean which was used to track a char *; just check if the pointer is NULL instead. Fixes bugs 5754 and 5793, hopefully without breaking anything. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@36608 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'asn1')
-rw-r--r--asn1/x509if/packet-x509if-template.c20
-rw-r--r--asn1/x509if/x509if.cnf28
2 files changed, 35 insertions, 13 deletions
diff --git a/asn1/x509if/packet-x509if-template.c b/asn1/x509if/packet-x509if-template.c
index 2c38b0b909..2d7c07fb7b 100644
--- a/asn1/x509if/packet-x509if-template.c
+++ b/asn1/x509if/packet-x509if-template.c
@@ -37,6 +37,7 @@
#include "packet-x509if.h"
#include "packet-x509sat.h"
#include <epan/strutil.h>
+#include <epan/dissectors/packet-frame.h>
#define PNAME "X.509 Information Framework"
#define PSNAME "X509IF"
@@ -51,13 +52,12 @@ static int hf_x509if_any_string = -1;
/* Initialize the subtree pointers */
#include "packet-x509if-ett.c"
-static const char *object_identifier_id;
+static const char *object_identifier_id = NULL;
static proto_tree *top_of_dn = NULL;
static proto_tree *top_of_rdn = NULL;
static gboolean rdn_one_value = FALSE; /* have we seen one value in an RDN yet */
static gboolean dn_one_rdn = FALSE; /* have we seen one RDN in a DN yet */
-static gboolean doing_dn = TRUE;
static gboolean doing_attr = FALSE;
#define MAX_RDN_STR_LEN 64
@@ -72,6 +72,22 @@ static value_string fmt_vals[MAX_FMT_VALS];
#define MAX_AVA_STR_LEN 64
static char *last_ava = NULL;
+static void
+x509if_frame_end(void)
+{
+ object_identifier_id = NULL;
+ top_of_dn = NULL;
+ top_of_rdn = NULL;
+
+ rdn_one_value = FALSE;
+ dn_one_rdn = FALSE;
+ doing_attr = FALSE;
+
+ last_dn = NULL;
+ last_rdn = NULL;
+ last_ava = NULL;
+}
+
#include "packet-x509if-fn.c"
const char * x509if_get_last_dn(void)
diff --git a/asn1/x509if/x509if.cnf b/asn1/x509if/x509if.cnf
index adbfd0386c..b3c0f32a1d 100644
--- a/asn1/x509if/x509if.cnf
+++ b/asn1/x509if/x509if.cnf
@@ -197,7 +197,7 @@ DistinguishedName B "2.16.840.1.101.2.2.1.140" "id-at-garrison"
name = oid_resolved_from_string(object_identifier_id);
if(!name) name = object_identifier_id;
- if(doing_dn) { /* append it to the RDN */
+ if(last_rdn) { /* append it to the RDN */
g_strlcat(last_rdn, name, MAX_RDN_STR_LEN);
g_strlcat(last_rdn, "=", MAX_RDN_STR_LEN);
@@ -213,6 +213,7 @@ DistinguishedName B "2.16.840.1.101.2.2.1.140" "id-at-garrison"
if((fmt = val_to_str(hf_index, fmt_vals, "")) && *fmt) {
/* we have a format */
last_ava = ep_alloc(MAX_AVA_STR_LEN); *last_ava = '\0';
+ register_frame_end_routine (x509if_frame_end);
g_snprintf(last_ava, MAX_AVA_STR_LEN, "%%s %%s", name, fmt);
@@ -245,7 +246,7 @@ DistinguishedName B "2.16.840.1.101.2.2.1.140" "id-at-garrison"
/* it was a string - format it */
value = tvb_format_text(out_tvb, 0, tvb_length(out_tvb));
- if(doing_dn) {
+ if(last_rdn) {
g_strlcat(last_rdn, value, MAX_RDN_STR_LEN);
/* append it to the tree*/
@@ -255,11 +256,15 @@ DistinguishedName B "2.16.840.1.101.2.2.1.140" "id-at-garrison"
if((fmt = val_to_str(ava_hf_index, fmt_vals, "")) && *fmt) {
/* we have a format */
- if(!(name = oid_resolved_from_string(object_identifier_id)))
- name = object_identifier_id;
- g_snprintf(last_ava, MAX_AVA_STR_LEN, "%%s %%s %%s", name, fmt, value);
+ if (!last_ava) {
+ last_ava = ep_alloc(MAX_AVA_STR_LEN);
+ }
- proto_item_append_text(tree, " %%s", last_ava);
+ if(!(name = oid_resolved_from_string(object_identifier_id)))
+ name = object_identifier_id;
+ g_snprintf(last_ava, MAX_AVA_STR_LEN, "%%s %%s %%s", name, fmt, value);
+
+ proto_item_append_text(tree, " %%s", last_ava);
}
}
@@ -330,7 +335,7 @@ DistinguishedName B "2.16.840.1.101.2.2.1.140" "id-at-garrison"
rdn_one_value = FALSE;
top_of_rdn = tree;
last_rdn = ep_alloc(MAX_DN_STR_LEN); *last_rdn = '\0';
- doing_dn = TRUE;
+ register_frame_end_routine (x509if_frame_end);
%(DEFAULT_BODY)s
@@ -349,7 +354,6 @@ DistinguishedName B "2.16.840.1.101.2.2.1.140" "id-at-garrison"
}
}
- doing_dn = FALSE;
last_rdn = NULL; /* it will get freed when the next packet is dissected */
#.FN_BODY RelativeDistinguishedName/_item
@@ -358,7 +362,7 @@ DistinguishedName B "2.16.840.1.101.2.2.1.140" "id-at-garrison"
top_of_rdn = tree;
} else {
- if(doing_dn)
+ if(last_rdn)
/* this is an additional value - delimit */
g_strlcat(last_rdn, "+", MAX_RDN_STR_LEN);
}
@@ -373,6 +377,8 @@ DistinguishedName B "2.16.840.1.101.2.2.1.140" "id-at-garrison"
dn_one_rdn = FALSE; /* reset */
last_dn = ep_alloc(MAX_DN_STR_LEN); *last_dn = '\0';
top_of_dn = NULL;
+ register_frame_end_routine (x509if_frame_end);
+
%(DEFAULT_BODY)s
@@ -402,6 +408,7 @@ DistinguishedName B "2.16.840.1.101.2.2.1.140" "id-at-garrison"
ava_hf_index = hf_index;
last_ava = ep_alloc(MAX_AVA_STR_LEN); *last_ava = '\0';
+ register_frame_end_routine (x509if_frame_end);
%(DEFAULT_BODY)s
@@ -409,10 +416,9 @@ DistinguishedName B "2.16.840.1.101.2.2.1.140" "id-at-garrison"
#.FN_BODY Attribute
doing_attr = TRUE;
+ register_frame_end_routine (x509if_frame_end);
%(DEFAULT_BODY)s
-
- doing_attr = FALSE;
#.END