aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-ldap.c
diff options
context:
space:
mode:
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2011-02-23 00:51:02 +0000
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2011-02-23 00:51:02 +0000
commit921e6d0b9dd70053272c7e0452507d2a17fa4b27 (patch)
treeadfd156482ef20ce84a4fb62abe389cf2e894b52 /epan/dissectors/packet-ldap.c
parentefdc54839ceb089538e440f552e1364565b0712b (diff)
Split get_dns_name() into get_dns_name() and expand_dns_name().
In dissect_ms_compressed_string() dissect_mscldap_string() simply call expand_dns_name() instead of using duplicate (and insecure) code. This *might* break CLDAP and SMB dissection. If that's the case we should probably revert get_dns_name() and simplify expand_dns_name(). Fixes infinite recursion errors found by joernchen of Phenoelit. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@36029 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors/packet-ldap.c')
-rw-r--r--epan/dissectors/packet-ldap.c80
1 files changed, 18 insertions, 62 deletions
diff --git a/epan/dissectors/packet-ldap.c b/epan/dissectors/packet-ldap.c
index cfd2c48db0..151d153f43 100644
--- a/epan/dissectors/packet-ldap.c
+++ b/epan/dissectors/packet-ldap.c
@@ -119,6 +119,7 @@
#include "packet-ber.h"
#include "packet-per.h"
+#include "packet-dns.h"
#define PNAME "Lightweight Directory Access Protocol"
#define PSNAME "LDAP"
@@ -339,7 +340,7 @@ static int hf_ldap_graceAuthNsRemaining = -1; /* INTEGER_0_maxInt */
static int hf_ldap_error = -1; /* T_error */
/*--- End of included file: packet-ldap-hf.c ---*/
-#line 186 "packet-ldap-template.c"
+#line 187 "packet-ldap-template.c"
/* Initialize the subtree pointers */
static gint ett_ldap = -1;
@@ -412,7 +413,7 @@ static gint ett_ldap_PasswordPolicyResponseValue = -1;
static gint ett_ldap_T_warning = -1;
/*--- End of included file: packet-ldap-ett.c ---*/
-#line 197 "packet-ldap-template.c"
+#line 198 "packet-ldap-template.c"
static dissector_table_t ldap_name_dissector_table=NULL;
static const char *object_identifier_id = NULL; /* LDAP OID */
@@ -3683,7 +3684,7 @@ static void dissect_PasswordPolicyResponseValue_PDU(tvbuff_t *tvb _U_, packet_in
/*--- End of included file: packet-ldap-fn.c ---*/
-#line 737 "packet-ldap-template.c"
+#line 738 "packet-ldap-template.c"
static void
dissect_ldap_payload(tvbuff_t *tvb, packet_info *pinfo,
@@ -4062,64 +4063,19 @@ dissect_ldap_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean i
}
}
-int dissect_mscldap_string(tvbuff_t *tvb, int offset, char *str, int maxlen, gboolean prepend_dot)
+/*
+ * prepend_dot is no longer used, but is being left in place in order to
+ * maintain ABI compatibility.
+ */
+int dissect_mscldap_string(tvbuff_t *tvb, int offset, char *str, int max_len, gboolean prepend_dot _U_)
{
- guint8 len;
-
- len=tvb_get_guint8(tvb, offset);
- offset+=1;
- *str=0;
- attributedesc_string=NULL;
-
- while(len){
- /* add potential field separation dot */
- if(prepend_dot){
- if(!maxlen){
- *str=0;
- return offset;
- }
- maxlen--;
- *str++='.';
- *str=0;
- }
-
- if(len==0xc0){
- int new_offset;
- /* ops its a mscldap compressed string */
-
- new_offset=tvb_get_guint8(tvb, offset);
- if (new_offset == offset - 1)
- THROW(ReportedBoundsError);
- offset+=1;
-
- dissect_mscldap_string(tvb, new_offset, str, maxlen, FALSE);
+ int compr_len;
+ const guchar *name;
- return offset;
- }
-
- prepend_dot=TRUE;
-
- if(maxlen<=len){
- if(maxlen>3){
- *str++='.';
- *str++='.';
- *str++='.';
- }
- *str=0;
- return offset; /* will mess up offset in caller, is unlikely */
- }
- tvb_memcpy(tvb, str, offset, len);
- str+=len;
- *str=0;
- maxlen-=len;
- offset+=len;
-
-
- len=tvb_get_guint8(tvb, offset);
- offset+=1;
- }
- *str=0;
- return offset;
+ /* The name data MUST start at offset 0 of the tvb */
+ compr_len = expand_dns_name(tvb, offset, max_len, 0, &name);
+ g_strlcpy(str, name, max_len);
+ return offset + compr_len;
}
@@ -5606,7 +5562,7 @@ void proto_register_ldap(void) {
NULL, HFILL }},
/*--- End of included file: packet-ldap-hfarr.c ---*/
-#line 2079 "packet-ldap-template.c"
+#line 2035 "packet-ldap-template.c"
};
/* List of subtrees */
@@ -5681,7 +5637,7 @@ void proto_register_ldap(void) {
&ett_ldap_T_warning,
/*--- End of included file: packet-ldap-ettarr.c ---*/
-#line 2092 "packet-ldap-template.c"
+#line 2048 "packet-ldap-template.c"
};
module_t *ldap_module;
@@ -5812,7 +5768,7 @@ proto_reg_handoff_ldap(void)
/*--- End of included file: packet-ldap-dis-tab.c ---*/
-#line 2206 "packet-ldap-template.c"
+#line 2162 "packet-ldap-template.c"
}