mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-24 00:29:35 -05:00
rdn check to prevent illegal rdns in modrdn (copied from dn_rdn) fixes ITS#1102
This commit is contained in:
parent
5c0502add9
commit
cd74b62fd2
2 changed files with 49 additions and 4 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue