char *p, *q, *s, *e;
int len = 0;
+ /* validator should have refused an empty string */
+ assert( val->bv_len );
+
p = val->bv_val;
/* Ignore initial whitespace */
for ( ; p < val->bv_val + val->bv_len && ASCII_SPACE( p[ 0 ] ); p++ );
normalized->bv_len = val->bv_len - (p - val->bv_val);
+
+ if( !normalized->bv_len ) {
+ ber_mem2bv( " ", 1, 1, normalized );
+ return LDAP_SUCCESS;
+ }
+
ber_mem2bv( p, normalized->bv_len, 1, normalized );
e = normalized->bv_val + normalized->bv_len;
{
char *p, *q;
+ /* validator should have refused an empty string */
+ assert( val->bv_len );
+
q = normalized->bv_val = ch_malloc( val->bv_len + 1 );
- for( p = val->bv_val; *p; p++ )
- if ( ! ( ASCII_SPACE( *p ) || *p == '-' ))
+ for( p = val->bv_val; *p; p++ ) {
+ if ( ! ( ASCII_SPACE( *p ) || *p == '-' )) {
*q++ = *p;
+ }
+ }
*q = '\0';
normalized->bv_len = q - normalized->bv_val;
+ if( normalized->bv_len == 0 ) {
+ free( normalized->bv_val );
+ return LDAP_INVALID_SYNTAX;
+ }
+
return LDAP_SUCCESS;
}
{
ber_len_t i;
+ if( val->bv_len == 0 ) return LDAP_INVALID_SYNTAX;
+
for(i=0; i < val->bv_len; i++) {
if( !SLAP_PRINTABLE(val->bv_val[i]) ) {
return LDAP_INVALID_SYNTAX;
Syntax *syntax,
struct berval *val )
{
- ber_len_t i;
+ ber_len_t i, len;
- for(i=0; i < val->bv_len; i++) {
- if( !SLAP_PRINTABLES(val->bv_val[i]) ) {
+ if( val->bv_len == 0 ) return LDAP_INVALID_SYNTAX;
+
+ for(i=0,len=0; i < val->bv_len; i++) {
+ int c = val->bv_val[i];
+
+ if( c == '$' ) {
+ if( len == 0 ) {
+ return LDAP_INVALID_SYNTAX;
+ }
+ len = 0;
+
+ } else if ( SLAP_PRINTABLE(c) ) {
+ len++;
+ } else {
return LDAP_INVALID_SYNTAX;
}
}
+ if( len == 0 ) LDAP_INVALID_SYNTAX;
+
return LDAP_SUCCESS;
}
{
ber_len_t i;
+ if( val->bv_len == 0 ) return LDAP_INVALID_SYNTAX;
+
for(i=0; i < val->bv_len; i++) {
if( !LDAP_ASCII(val->bv_val[i]) ) {
return LDAP_INVALID_SYNTAX;
{
char *p, *q;
+ assert( val->bv_len );
+
p = val->bv_val;
/* Ignore initial whitespace */
normalized->bv_len = q - normalized->bv_val;
+ if( normalized->bv_len == 0 ) {
+ normalized->bv_val = ch_realloc( normalized->bv_val, 2 );
+ normalized->bv_val[0] = ' ';
+ normalized->bv_val[1] = '\0';
+ normalized->bv_len = 1;
+ }
+
return LDAP_SUCCESS;
}
{
ber_len_t i;
+ if( in->bv_len == 0 ) return LDAP_INVALID_SYNTAX;
+
for(i=0; i < in->bv_len; i++) {
if( !SLAP_NUMERIC(in->bv_val[i]) ) {
return LDAP_INVALID_SYNTAX;
/* removal all spaces */
char *p, *q;
+ assert( val->bv_len );
+
normalized->bv_val = ch_malloc( val->bv_len + 1 );
p = val->bv_val;
normalized->bv_len = q - normalized->bv_val;
+ if( normalized->bv_len == 0 ) {
+ normalized->bv_val = ch_realloc( normalized->bv_val, 2 );
+ normalized->bv_val[0] = ' ';
+ normalized->bv_val[1] = '\0';
+ normalized->bv_len = 1;
+ }
+
return LDAP_SUCCESS;
}