rdn check to prevent illegal rdns in modrdn (copied from dn_rdn) fixes ITS#1102

This commit is contained in:
Pierangelo Masarati 2001-07-05 08:40:40 +00:00
parent 5c0502add9
commit cd74b62fd2
2 changed files with 49 additions and 4 deletions

View file

@ -479,7 +479,7 @@ ldbm_back_modrdn(
/* Not a big deal but we may say something */
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
"ldbm_back_modrdn: old_rdn_type=%s new_rdn_type-%s\n",
"ldbm_back_modrdn: old_rdn_type=%s new_rdn_type=%s\n",
old_rdn_type, new_rdn_type ));
#else
Debug( LDAP_DEBUG_TRACE,

View file

@ -486,10 +486,55 @@ rdn_attr_value( const char * rdn )
}
int rdn_validate( const char * rdn )
/* rdn_validate:
*
* 1 if rdn is a legal rdn;
* 0 otherwise (including a sequence of rdns)
*/
int
rdn_validate( const char * rdn )
{
/* just a simple check for now */
return strchr( rdn, '=' ) != NULL;
int inquote;
if ( rdn == NULL ) {
return( 0 );
}
if ( strchr( rdn, '=' ) == NULL ) {
return( 0 );
}
while ( *rdn && ASCII_SPACE( *rdn ) ) {
rdn++;
}
if( *rdn == '\0' ) {
return( 0 );
}
inquote = 0;
for ( ; *rdn; rdn++ ) {
if ( *rdn == '\\' ) {
if ( *(rdn + 1) ) {
rdn++;
}
continue;
}
if ( inquote ) {
if ( *rdn == '"' ) {
inquote = 0;
}
} else {
if ( *rdn == '"' ) {
inquote = 1;
} else if ( DN_SEPARATOR( *rdn ) ) {
return( 0 );
}
}
}
return( 1 );
}