From 449c9aabb21fce99249c0cc82f3f80767284d908 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 14 Jan 2015 10:35:20 +0000 Subject: [PATCH] Fix UTF8stringvalidate loop termination (coverity) --- servers/slapd/schema_init.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index a80f99e3bc..98d0c8a83a 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -1780,16 +1780,15 @@ UTF8StringValidate( Syntax *syntax, struct berval *in ) { - ber_len_t count; int len; - unsigned char *u = (unsigned char *)in->bv_val; + unsigned char *u = (unsigned char *)in->bv_val, *end = in->bv_val + in->bv_len; if( BER_BVISEMPTY( in ) && syntax == slap_schema.si_syn_directoryString ) { /* directory strings cannot be empty */ return LDAP_INVALID_SYNTAX; } - for( count = in->bv_len; count > 0; count -= len, u += len ) { + for( ; u < end; u += len ) { /* get the length indicated by the first byte */ len = LDAP_UTF8_CHARLEN2( u, len ); @@ -1827,7 +1826,7 @@ UTF8StringValidate( if( LDAP_UTF8_OFFSET( (char *)u ) != len ) return LDAP_INVALID_SYNTAX; } - if( count != 0 ) { + if( u >= len ) { return LDAP_INVALID_SYNTAX; } -- 2.39.5