diff options
author | Gerald Combs <gerald@wireshark.org> | 2011-02-23 00:51:02 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2011-02-23 00:51:02 +0000 |
commit | 47837956900070b04a47f0289de3fb0ce2c3251c (patch) | |
tree | adfd156482ef20ce84a4fb62abe389cf2e894b52 /asn1 | |
parent | 740c1c4aeb072e81b13b95020a1547da8eecffbf (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.
svn path=/trunk/; revision=36029
Diffstat (limited to 'asn1')
-rw-r--r-- | asn1/ldap/packet-ldap-template.c | 68 | ||||
-rw-r--r-- | asn1/ldap/packet-ldap-template.h | 2 |
2 files changed, 13 insertions, 57 deletions
diff --git a/asn1/ldap/packet-ldap-template.c b/asn1/ldap/packet-ldap-template.c index 56bd4793ca..5e4d7797b2 100644 --- a/asn1/ldap/packet-ldap-template.c +++ b/asn1/ldap/packet-ldap-template.c @@ -111,6 +111,7 @@ #include "packet-ber.h" #include "packet-per.h" +#include "packet-dns.h" #define PNAME "Lightweight Directory Access Protocol" #define PSNAME "LDAP" @@ -1112,64 +1113,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; } diff --git a/asn1/ldap/packet-ldap-template.h b/asn1/ldap/packet-ldap-template.h index bed5466e36..818195d335 100644 --- a/asn1/ldap/packet-ldap-template.h +++ b/asn1/ldap/packet-ldap-template.h @@ -103,7 +103,7 @@ typedef struct ldap_call_response { void register_ldap_name_dissector_handle(const char *attr_type, dissector_handle_t dissector); void register_ldap_name_dissector(const char *attr_type, dissector_t dissector, int proto); -int dissect_mscldap_string(tvbuff_t *tvb, int offset, char *str, int maxlen, gboolean prepend_dot); +int dissect_mscldap_string(tvbuff_t *tvb, int offset, char *str, int max_len, gboolean prepend_dot _U_); /*#include "packet-ldap-exp.h" */ |