aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-ldap.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2005-11-27 02:42:29 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2005-11-27 02:42:29 +0000
commit75b053261fb1ddb6170eb386a1ea09fa3175fb1d (patch)
tree3ce14fe1e48a213581d12f2dc1c52e4655c411a6 /epan/dissectors/packet-ldap.c
parent996c0f6cc39ebc92c159b1155897d35ded9d60dd (diff)
Don't do anything to the filter string until we've successfully parsed
the extensibleMatch. Make sure the filter string is always null-terminated, as we use "strlen()" to skip to the end of it. On the (illegal, but not impossible) chance that we have more than one matching rule ID, attributeDescription, or matchValue, free any we already have before fetching a new one. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@16609 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors/packet-ldap.c')
-rw-r--r--epan/dissectors/packet-ldap.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/epan/dissectors/packet-ldap.c b/epan/dissectors/packet-ldap.c
index 49777ba778..622e72f2ea 100644
--- a/epan/dissectors/packet-ldap.c
+++ b/epan/dissectors/packet-ldap.c
@@ -811,14 +811,9 @@ static int parse_filter_extensibleMatch(ASN1_SCK *a, char **filter, guint *filte
* expression
*/
matchingRule = type = matchValue = NULL;
- dnAttributes = 0;
+ dnAttributes = FALSE;
end = a->offset + byte_length;
- filterp = *filter + strlen(*filter);
- *filter_length += 1; /* For the ( */
- *filter = g_realloc(*filter, *filter_length);
- *filterp++ = '(';
-
while (a->offset < end) {
/*
* Now, parse out each of those items
@@ -841,6 +836,10 @@ static int parse_filter_extensibleMatch(ASN1_SCK *a, char **filter, guint *filte
switch (tag) {
case 0x01: /* Parse Matching Rule Id */
+ if (matchingRule != NULL) {
+ g_free(matchingRule);
+ matchingRule = NULL;
+ }
ret = asn1_string_value_decode(a, (int) string_length, &matchingRule);
if (ret != ASN1_ERR_NOERROR) {
return ret;
@@ -848,6 +847,10 @@ static int parse_filter_extensibleMatch(ASN1_SCK *a, char **filter, guint *filte
break;
case 0x02: /* Parse attributeDescription */
+ if (type != NULL) {
+ g_free(type);
+ type = NULL;
+ }
ret = asn1_string_value_decode(a, (int) string_length, &type);
if (ret != ASN1_ERR_NOERROR) {
return ret;
@@ -855,6 +858,10 @@ static int parse_filter_extensibleMatch(ASN1_SCK *a, char **filter, guint *filte
break;
case 0x03: /* Parse the matchValue */
+ if (matchValue != NULL) {
+ g_free(matchValue);
+ matchValue = NULL;
+ }
ret = asn1_string_value_decode(a, (int) string_length, &matchValue);
if (ret != ASN1_ERR_NOERROR) {
return ret;
@@ -877,7 +884,12 @@ static int parse_filter_extensibleMatch(ASN1_SCK *a, char **filter, guint *filte
/*
* Now, fill in the filter string
*/
-
+ filterp = *filter + strlen(*filter);
+ *filter_length += 1; /* For the ( */
+ *filter = g_realloc(*filter, *filter_length);
+ *filterp++ = '(';
+ *filterp = '\0';
+
if (type) {
if (strlen(type) > 0) {
*filter_length += 1 + strlen(type);