From 903b982fcf5f3f6a627afa2a2af1392c9cfb3d67 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sun, 18 Jan 2015 14:21:05 +0000 Subject: [PATCH] Minor cleanup (coverity) --- servers/slapd/schema_check.c | 1 + servers/slapd/schema_init.c | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/servers/slapd/schema_check.c b/servers/slapd/schema_check.c index 9bfda27547..c5d63673c4 100644 --- a/servers/slapd/schema_check.c +++ b/servers/slapd/schema_check.c @@ -815,6 +815,7 @@ entry_naming_check( "value of naming attribute '%s' in unsupported BER form", ava->la_attr.bv_val ); rc = LDAP_NAMING_VIOLATION; + break; } rc = slap_bv2ad( &ava->la_attr, &desc, &errtext ); diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index c1ca86f854..e702e19749 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -1735,16 +1735,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 ); @@ -1782,7 +1781,7 @@ UTF8StringValidate( if( LDAP_UTF8_OFFSET( (char *)u ) != len ) return LDAP_INVALID_SYNTAX; } - if( count != 0 ) { + if( u > end ) { return LDAP_INVALID_SYNTAX; } @@ -2636,8 +2635,10 @@ integerIndexer( itmp.bv_len = maxstrlen; } rc = integerVal2Key( &values[i], &keys[i], &itmp, ctx ); - if ( rc ) + if ( rc ) { + slap_sl_free( keys, ctx ); goto func_leave; + } } *keysp = keys; func_leave: @@ -2684,12 +2685,16 @@ integerFilter( } rc = integerVal2Key( value, keys, &iv, ctx ); - if ( rc == 0 ) - *keysp = keys; if ( iv.bv_val != ibuf ) { slap_sl_free( iv.bv_val, ctx ); } + + if ( rc == 0 ) + *keysp = keys; + else + slap_sl_free( keys, ctx ); + return rc; } @@ -3265,6 +3270,7 @@ serialNumberAndIssuerCheck( } if ( is->bv_val[is->bv_len+1] == '"' ) { /* double dquote */ + numdquotes++; is->bv_len += 2; continue; } @@ -3842,6 +3848,7 @@ issuerAndThisUpdateCheck( } if ( is->bv_val[is->bv_len+1] == '"' ) { /* double dquote */ + numdquotes++; is->bv_len += 2; continue; } @@ -4384,6 +4391,7 @@ serialNumberAndIssuerSerialCheck( } if ( is->bv_val[is->bv_len + 1] == '"' ) { /* double dquote */ + numdquotes++; is->bv_len += 2; continue; } -- 2.39.5