diff options
Diffstat (limited to 'asn1/ldap/packet-ldap-template.c')
-rw-r--r-- | asn1/ldap/packet-ldap-template.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/asn1/ldap/packet-ldap-template.c b/asn1/ldap/packet-ldap-template.c index b3944797d9..ab6c2ee541 100644 --- a/asn1/ldap/packet-ldap-template.c +++ b/asn1/ldap/packet-ldap-template.c @@ -73,6 +73,7 @@ #include <stdio.h> #include <string.h> +#include <ctype.h> #include <glib.h> @@ -248,8 +249,8 @@ ldap_info_equal_unmatched(gconstpointer k1, gconstpointer k2) /* This string contains the last AssertionValue that was decoded */ static char *assertionvalue_string=NULL; -/* if the octet string contain all ascii characters then display it as - * a string othervise just display it in hex. +/* if the octet string contain all printable ASCII characters, then + * display it as a string, othervise just display it in hex. */ static int dissect_ldap_AssertionValue(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) @@ -258,7 +259,7 @@ dissect_ldap_AssertionValue(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset gboolean pc, ind, is_ascii; gint32 tag; guint32 len, i; - char *str; + const guchar *str; offset=get_ber_identifier(tvb, offset, &class, &pc, &tag); offset=get_ber_length(NULL, tvb, offset, &len, &ind); @@ -267,21 +268,26 @@ dissect_ldap_AssertionValue(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset return offset; } - /* check whether the string is ascii or binary */ + /* + * Check whether the string is printable ASCII or binary. + * + * XXX - should we support reading RFC 2252-style schemas + * for LDAP, and using that to determine how to display + * attribute values and assertion values? + */ str=tvb_get_ptr(tvb, offset, len); is_ascii=TRUE; for(i=0;i<len;i++){ - if(str[i]<0x20){ + if(!isascii(str[i]) || !isprint(str[i])){ is_ascii=FALSE; + break; } } /* convert the string into a printable string */ if(is_ascii){ assertionvalue_string=ep_alloc(len+1); - for(i=0;i<len;i++){ - assertionvalue_string[i]=str[i]; - } + memcpy(assertionvalue_string,str,len); assertionvalue_string[i]=0; } else { assertionvalue_string=ep_alloc(3*len); |