aboutsummaryrefslogtreecommitdiffstats
path: root/asn1/ldap/packet-ldap-template.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2006-06-13 05:39:55 +0000
committerGuy Harris <guy@alum.mit.edu>2006-06-13 05:39:55 +0000
commit6d2e9ee5f7528497f89d816d74d19babdde3d591 (patch)
treef3b04f3f9d269ddc23379a4ed4c529331f78fa50 /asn1/ldap/packet-ldap-template.c
parentc922f5e48e8caa10955de348af582bd340ba1709 (diff)
Constify to fix compiler warnings.
Check for printable ASCII - 0x7F is >= 0x20, but it's not printable, and 0x80 through 0xFF aren't ASCII. Note that we should perhaps be using RFC 2252-style schemas to figure out which attribute and assertion values are text and which are binary. svn path=/trunk/; revision=18447
Diffstat (limited to 'asn1/ldap/packet-ldap-template.c')
-rw-r--r--asn1/ldap/packet-ldap-template.c22
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);