/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2014 The OpenLDAP Foundation.
+ * Copyright 1998-2015 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 );
if( LDAP_UTF8_OFFSET( (char *)u ) != len ) return LDAP_INVALID_SYNTAX;
}
- if( count != 0 ) {
+ if( u > end ) {
return LDAP_INVALID_SYNTAX;
}
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:
}
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;
}
}
if ( is->bv_val[is->bv_len+1] == '"' ) {
/* double dquote */
+ numdquotes++;
is->bv_len += 2;
continue;
}
}
if ( is->bv_val[is->bv_len+1] == '"' ) {
/* double dquote */
+ numdquotes++;
is->bv_len += 2;
continue;
}
}
if ( is->bv_val[is->bv_len + 1] == '"' ) {
/* double dquote */
+ numdquotes++;
is->bv_len += 2;
continue;
}