mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-01-02 04:59:39 -05:00
Converted all use of dn_parent to the in-place version. (Fixed a pdn leak
in back-sql along the way.)
This commit is contained in:
parent
a06bc9007c
commit
e2c2de11c3
16 changed files with 22 additions and 65 deletions
|
|
@ -93,7 +93,7 @@ retry: rc = txn_abort( ltid );
|
|||
* If the parent does not exist, only allow the "root" user to
|
||||
* add the entry.
|
||||
*/
|
||||
pdn = dn_parent1( be, e->e_ndn );
|
||||
pdn = dn_parent( be, e->e_ndn );
|
||||
|
||||
if( pdn != NULL && *pdn != '\0' ) {
|
||||
Entry *matched = NULL;
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ retry: /* transaction retry */
|
|||
goto done;
|
||||
}
|
||||
|
||||
pdn = dn_parent1( be, ndn );
|
||||
pdn = dn_parent( be, ndn );
|
||||
|
||||
if( pdn != NULL && *pdn != '\0' ) {
|
||||
/* get parent */
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ bdb_dn2id_add(
|
|||
goto done;
|
||||
}
|
||||
|
||||
pdn = dn_parent1( be, ptr );
|
||||
pdn = dn_parent( be, ptr );
|
||||
|
||||
if( pdn != NULL ) {
|
||||
key.size -= pdn - ptr;
|
||||
|
|
@ -86,7 +86,7 @@ bdb_dn2id_add(
|
|||
goto done;
|
||||
}
|
||||
ptr = pdn;
|
||||
pdn = dn_parent1( be, pdn );
|
||||
pdn = dn_parent( be, pdn );
|
||||
}
|
||||
|
||||
while( pdn != NULL ) {
|
||||
|
|
@ -106,7 +106,7 @@ bdb_dn2id_add(
|
|||
break;
|
||||
}
|
||||
ptr = pdn;
|
||||
pdn = dn_parent1( be, pdn );
|
||||
pdn = dn_parent( be, pdn );
|
||||
}
|
||||
|
||||
done:
|
||||
|
|
@ -157,7 +157,7 @@ bdb_dn2id_delete(
|
|||
goto done;
|
||||
}
|
||||
|
||||
pdn = dn_parent1( be, ptr );
|
||||
pdn = dn_parent( be, ptr );
|
||||
|
||||
if( pdn != NULL ) {
|
||||
key.size -= pdn - ptr;
|
||||
|
|
@ -184,7 +184,7 @@ bdb_dn2id_delete(
|
|||
goto done;
|
||||
}
|
||||
ptr = pdn;
|
||||
pdn = dn_parent1( be, pdn );
|
||||
pdn = dn_parent( be, pdn );
|
||||
}
|
||||
|
||||
while( pdn != NULL ) {
|
||||
|
|
@ -203,7 +203,7 @@ bdb_dn2id_delete(
|
|||
goto done;
|
||||
}
|
||||
ptr = pdn;
|
||||
pdn = dn_parent1( be, pdn );
|
||||
pdn = dn_parent( be, pdn );
|
||||
}
|
||||
|
||||
done:
|
||||
|
|
@ -291,7 +291,7 @@ bdb_dn2id_matched(
|
|||
rc = db->get( db, txn, &key, &data, bdb->bi_db_opflags );
|
||||
|
||||
if( rc == DB_NOTFOUND ) {
|
||||
char *pdn = dn_parent1( be, dn );
|
||||
char *pdn = dn_parent( be, dn );
|
||||
|
||||
if( pdn == NULL || *pdn == '\0' ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ retry: /* transaction retry */
|
|||
goto done;
|
||||
}
|
||||
|
||||
p_ndn = dn_parent1( be, e->e_ndn );
|
||||
p_ndn = dn_parent( be, e->e_ndn );
|
||||
np_ndn = p_ndn;
|
||||
if ( p_ndn != NULL && p_ndn[ 0 ] != '\0' ) {
|
||||
/* Make sure parent entry exist and we can write its
|
||||
|
|
@ -204,7 +204,7 @@ retry: /* transaction retry */
|
|||
"bdb_modrdn: wr to children of entry %s OK\n",
|
||||
p_ndn, 0, 0 );
|
||||
|
||||
p_dn = dn_parent1( be, e->e_dn );
|
||||
p_dn = dn_parent( be, e->e_dn );
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_modrdn: parent dn=%s\n",
|
||||
|
|
|
|||
|
|
@ -328,7 +328,7 @@ bdb_search(
|
|||
|
||||
/* need to skip alias which deref into scope */
|
||||
if( scope & LDAP_SCOPE_ONELEVEL ) {
|
||||
char *pdn = dn_parent1( NULL, e->e_ndn );
|
||||
char *pdn = dn_parent( NULL, e->e_ndn );
|
||||
if ( pdn != NULL ) {
|
||||
if( strcmp( pdn, realbase ) ) {
|
||||
goto loop_continue;
|
||||
|
|
@ -377,7 +377,7 @@ bdb_search(
|
|||
|
||||
/* check scope */
|
||||
if ( !scopeok && scope == LDAP_SCOPE_ONELEVEL ) {
|
||||
if ( (dn = dn_parent1( be, e->e_ndn )) != NULL ) {
|
||||
if ( (dn = dn_parent( be, e->e_ndn )) != NULL ) {
|
||||
scopeok = (dn == realbase)
|
||||
? 1
|
||||
: (strcmp( dn, realbase ) ? 0 : 1 );
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ ID bdb_tool_entry_put(
|
|||
}
|
||||
|
||||
/* add dn2id indices */
|
||||
pdn = dn_parent1( be, e->e_ndn );
|
||||
pdn = dn_parent( be, e->e_ndn );
|
||||
rc = bdb_dn2id_add( be, tid, pdn, e );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
|
|
@ -237,7 +237,7 @@ int bdb_tool_entry_reindex(
|
|||
(long) id, e->e_dn, 0 );
|
||||
|
||||
/* add dn2id indices */
|
||||
pdn = dn_parent1( be, e->e_ndn );
|
||||
pdn = dn_parent( be, e->e_ndn );
|
||||
rc = bdb_dn2id_add( be, tid, pdn, e );
|
||||
if( rc != 0 && rc != DB_KEYEXIST ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
|
|
|
|||
|
|
@ -123,15 +123,12 @@ ldbm_back_add(
|
|||
ber_bvecfree( refs );
|
||||
free( matched_dn );
|
||||
|
||||
free( pdn );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* don't need the add lock anymore */
|
||||
ldap_pvt_thread_mutex_unlock(&li->li_add_mutex);
|
||||
|
||||
free(pdn);
|
||||
|
||||
if ( ! access_allowed( be, conn, op, p,
|
||||
children, NULL, ACL_WRITE ) )
|
||||
{
|
||||
|
|
@ -205,7 +202,6 @@ ldbm_back_add(
|
|||
} else {
|
||||
if(pdn != NULL) {
|
||||
assert( *pdn == '\0' );
|
||||
free(pdn);
|
||||
}
|
||||
|
||||
/* no parent, must be adding entry to root */
|
||||
|
|
|
|||
|
|
@ -243,8 +243,6 @@ ldbm_back_delete(
|
|||
rc = 0;
|
||||
|
||||
return_results:;
|
||||
if ( pdn != NULL ) free(pdn);
|
||||
|
||||
if( p != NULL ) {
|
||||
/* free parent and writer lock */
|
||||
cache_return_entry_w( &li->li_cache, p );
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ dn2id_add(
|
|||
free( key.dptr );
|
||||
|
||||
if ( rc != -1 ) {
|
||||
char *pdn = dn_parent( NULL, dn );
|
||||
char *pdn = dn_parent( be, dn );
|
||||
|
||||
if( pdn != NULL ) {
|
||||
ldbm_datum_init( key );
|
||||
|
|
@ -75,7 +75,6 @@ dn2id_add(
|
|||
rc = idl_insert_key( be, db, key, id );
|
||||
ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex );
|
||||
free( key.dptr );
|
||||
free( pdn );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -297,7 +296,7 @@ dn2id_delete(
|
|||
|
||||
|
||||
{
|
||||
char *pdn = dn_parent( NULL, dn );
|
||||
char *pdn = dn_parent( be, dn );
|
||||
|
||||
if( pdn != NULL ) {
|
||||
ldbm_datum_init( key );
|
||||
|
|
@ -310,7 +309,6 @@ dn2id_delete(
|
|||
ldap_pvt_thread_mutex_unlock( &db->dbc_write_mutex );
|
||||
|
||||
free( key.dptr );
|
||||
free( pdn );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -425,7 +423,6 @@ dn2entry_rw(
|
|||
if ( (e = dn2entry_r( be, pdn, matched )) != NULL ) {
|
||||
*matched = e;
|
||||
}
|
||||
free( pdn );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -790,9 +790,6 @@ return_results:
|
|||
if( new_dn != NULL ) free( new_dn );
|
||||
if( new_ndn != NULL ) free( new_ndn );
|
||||
|
||||
if( p_dn != NULL ) free( p_dn );
|
||||
if( p_ndn != NULL ) free( p_ndn );
|
||||
|
||||
/* LDAP v2 supporting correct attribute handling. */
|
||||
if( new_rdn_types != NULL ) charray_free( new_rdn_types );
|
||||
if( new_rdn_vals != NULL ) charray_free( new_rdn_vals );
|
||||
|
|
|
|||
|
|
@ -346,7 +346,6 @@ searchit:
|
|||
free( pdn );
|
||||
goto loop_continue;
|
||||
}
|
||||
free(pdn);
|
||||
}
|
||||
|
||||
} else if ( dn_issuffix( e->e_ndn, realbase ) ) {
|
||||
|
|
@ -379,12 +378,9 @@ searchit:
|
|||
/* check scope */
|
||||
if ( !scopeok && scope == LDAP_SCOPE_ONELEVEL ) {
|
||||
if ( (dn = dn_parent( be, e->e_ndn )) != NULL ) {
|
||||
(void) dn_normalize( dn );
|
||||
scopeok = (dn == realbase)
|
||||
? 1
|
||||
: (strcmp( dn, realbase ) ? 0 : 1 );
|
||||
free( dn );
|
||||
|
||||
} else {
|
||||
scopeok = (realbase == NULL || *realbase == '\0');
|
||||
}
|
||||
|
|
@ -433,12 +429,9 @@ searchit:
|
|||
/* check scope */
|
||||
if ( !scopeok && scope == LDAP_SCOPE_ONELEVEL ) {
|
||||
if ( (dn = dn_parent( be, e->e_ndn )) != NULL ) {
|
||||
(void) dn_normalize( dn );
|
||||
scopeok = (dn == realbase)
|
||||
? 1
|
||||
: (strcmp( dn, realbase ) ? 0 : 1 );
|
||||
free( dn );
|
||||
|
||||
} else {
|
||||
scopeok = (realbase == NULL || *realbase == '\0');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -195,7 +195,6 @@ monitor_cache_dn2entry(
|
|||
/* try with parent/ancestors */
|
||||
p_ndn = dn_parent( NULL, ndn );
|
||||
rc = monitor_cache_dn2entry( mi, p_ndn, &e_parent );
|
||||
free( p_ndn );
|
||||
if ( rc || e_parent == NULL) {
|
||||
return( -1 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ passwd_back_search(
|
|||
vals[0] = &val;
|
||||
vals[1] = NULL;
|
||||
|
||||
matched = ch_strdup( base );
|
||||
matched = base;
|
||||
|
||||
if( scope != LDAP_SCOPE_ONELEVEL ) {
|
||||
char *type;
|
||||
|
|
@ -191,7 +191,7 @@ passwd_back_search(
|
|||
int i;
|
||||
for( i=0; be->be_nsuffix[i] != NULL; i++ ) {
|
||||
if( dn_issuffix( nbase, be->be_nsuffix[i]->bv_val ) ) {
|
||||
matched = ch_strdup( be->be_suffix[i] );
|
||||
matched = be->be_suffix[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -212,7 +212,6 @@ passwd_back_search(
|
|||
|
||||
if ( (pw = getpwnam( user )) == NULL ) {
|
||||
matched = parent;
|
||||
parent = NULL;
|
||||
err = LDAP_NO_SUCH_OBJECT;
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -233,8 +232,6 @@ done:
|
|||
err, err == LDAP_NO_SUCH_OBJECT ? matched : NULL, NULL,
|
||||
NULL, NULL );
|
||||
|
||||
if( matched != NULL ) free( matched );
|
||||
if( parent != NULL ) free( parent );
|
||||
if( rdn != NULL ) free( rdn );
|
||||
if( user != NULL ) free( user );
|
||||
|
||||
|
|
|
|||
|
|
@ -336,8 +336,6 @@ int backsql_modrdn(BackendDB *be,Connection *conn,Operation *op,
|
|||
send_ldap_result(conn,op,LDAP_SUCCESS,"",NULL,NULL,NULL);
|
||||
modrdn_return:
|
||||
SQLFreeStmt(sth,SQL_DROP);
|
||||
if (p_dn)
|
||||
ch_free(p_dn);
|
||||
if (newSuperior && new_pdn)
|
||||
ch_free(new_pdn);
|
||||
if (new_dn)
|
||||
|
|
@ -462,7 +460,6 @@ int backsql_add(BackendDB *be,Connection *conn,Operation *op,Entry *e)
|
|||
send_ldap_result(conn,op,LDAP_OTHER,"","SQL-backend error",NULL,NULL);
|
||||
return 1;
|
||||
}
|
||||
free(pdn);
|
||||
backsql_BindParamStr(sth,1,e->e_dn,BACKSQL_MAX_DN_LEN);
|
||||
SQLBindParameter(sth,2,SQL_PARAM_INPUT,SQL_C_LONG,SQL_INTEGER,0,0,&oc->id,0,0);
|
||||
SQLBindParameter(sth,3,SQL_PARAM_INPUT,SQL_C_LONG,SQL_INTEGER,0,0,&parent_id.id,0,0);
|
||||
|
|
|
|||
|
|
@ -313,11 +313,11 @@ dn_match( const char *val, const char *asserted )
|
|||
}
|
||||
|
||||
/*
|
||||
* dn_parent1 - return the dn's parent, in-place
|
||||
* dn_parent - return the dn's parent, in-place
|
||||
*/
|
||||
|
||||
char *
|
||||
dn_parent1(
|
||||
dn_parent(
|
||||
Backend *be,
|
||||
const char *dn )
|
||||
{
|
||||
|
|
@ -369,22 +369,6 @@ dn_parent1(
|
|||
return "";
|
||||
}
|
||||
|
||||
/*
|
||||
* dn_parent - return a copy of the dn of dn's parent
|
||||
*/
|
||||
|
||||
char *
|
||||
dn_parent(
|
||||
Backend *be,
|
||||
const char *dn
|
||||
)
|
||||
{
|
||||
dn = dn_parent1( be, dn );
|
||||
if( dn != NULL )
|
||||
dn = ch_strdup( dn );
|
||||
return (char *)dn;
|
||||
}
|
||||
|
||||
char * dn_rdn(
|
||||
Backend *be,
|
||||
const char *dn_in )
|
||||
|
|
@ -449,7 +433,7 @@ char **dn_subtree(
|
|||
do {
|
||||
charray_add( &subtree, dn );
|
||||
|
||||
dn = dn_parent1( be, dn );
|
||||
dn = dn_parent( be, dn );
|
||||
|
||||
} while ( dn != NULL );
|
||||
|
||||
|
|
|
|||
|
|
@ -319,7 +319,6 @@ LDAP_SLAPD_F (char *) dn_validate LDAP_P(( char *dn ));
|
|||
LDAP_SLAPD_F (char *) dn_normalize LDAP_P(( char *dn ));
|
||||
LDAP_SLAPD_F (int) dn_match LDAP_P(( const char *val, const char *asserted ));
|
||||
LDAP_SLAPD_F (char *) dn_parent LDAP_P(( Backend *be, const char *dn ));
|
||||
LDAP_SLAPD_F (char *) dn_parent1 LDAP_P(( Backend *be, const char *dn ));
|
||||
LDAP_SLAPD_F (char **) dn_subtree LDAP_P(( Backend *be, const char *dn ));
|
||||
LDAP_SLAPD_F (char *) dn_rdn LDAP_P(( Backend *be, const char *dn ));
|
||||
LDAP_SLAPD_F (int) dn_issuffix LDAP_P(( const char *dn, const char *suffix ));
|
||||
|
|
|
|||
Loading…
Reference in a new issue