Changed dn2entry to always returned a modified matched.

Modified users of this code to free matched if set.
This commit is contained in:
Kurt Zeilenga 1998-11-23 20:08:25 +00:00
parent 90debec329
commit b2ec7af331
9 changed files with 25 additions and 32 deletions

View File

@ -82,7 +82,6 @@ ldbm_back_add(
if ( (pdn = dn_parent( be, dn )) != NULL ) {
char *matched;
/* no parent */
matched = NULL;
/* get entry with reader lock */
if ( (p = dn2entry_r( be, pdn, &matched )) == NULL ) {
@ -90,6 +89,7 @@ ldbm_back_add(
0, 0 );
send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT,
matched, "" );
if ( matched != NULL ) {
free( matched );
}
@ -97,9 +97,6 @@ ldbm_back_add(
rc = -1;
goto return_results;
}
if ( matched != NULL ) {
free( matched );
}
if ( ! access_allowed( be, conn, op, p, "children", NULL,
op->o_dn, ACL_WRITE ) ) {

View File

@ -112,7 +112,7 @@ char *derefDN ( Backend *be,
)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
char *matched = NULL;
char *matched;
char *newDN = NULL;
int depth;
Entry *eMatched;
@ -135,7 +135,7 @@ char *derefDN ( Backend *be,
/* free reader lock */
cache_return_entry_r(&li->li_cache, eMatched);
if (*matched) {
if ((matched != NULL) && *matched) {
char *submatch;
/*
@ -155,6 +155,7 @@ char *derefDN ( Backend *be,
if ((eNew = derefAlias_r( be, conn, op, eMatched )) == NULL) {
free (matched);
matched = NULL;
free (newDN);
newDN = NULL;
free (remainder);
@ -169,6 +170,7 @@ char *derefDN ( Backend *be,
free (newDN);
newDN = NULL;
free (matched);
matched = NULL;
free (remainder);
break;
}
@ -178,13 +180,13 @@ char *derefDN ( Backend *be,
* the new dn together
*/
free (newDN);
free (matched);
newDN = ch_malloc (strlen(eMatched->e_dn) + rlen + 1);
strcpy (newDN, remainder);
strcat (newDN, eMatched->e_dn);
Debug( LDAP_DEBUG_TRACE, "<= expanded to %s\n", newDN, 0, 0 );
free (matched);
matched = NULL;
free (remainder);
/* free reader lock */
@ -234,7 +236,7 @@ char *derefDN ( Backend *be,
}
Debug( LDAP_DEBUG_TRACE, "<= returning deref DN of %s\n", newDN, 0, 0 );
free(matched);
if (matched != NULL) free(matched);
return newDN;
}

View File

@ -126,7 +126,7 @@ ldbm_back_bind(
Entry *e;
Attribute *a;
int rc;
char *matched = NULL;
char *matched;
#ifdef HAVE_KERBEROS
char krbname[MAX_K_NAME_SZ + 1];
AUTH_DAT ad;

View File

@ -29,6 +29,8 @@ ldbm_back_compare(
/* get entry with reader lock */
if ( (e = dn2entry_r( be, dn, &matched )) == NULL ) {
send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, "" );
if(matched == NULL) free(matched);
return( 1 );
}

View File

@ -20,7 +20,7 @@ ldbm_back_delete(
)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
char *matched = NULL;
char *matched;
char *pdn = NULL;
Entry *e, *p;
@ -66,7 +66,6 @@ ldbm_back_delete(
/* XXX delete from parent's id2children entry XXX */
pdn = dn_parent( be, dn );
matched = NULL;
p = dn2entry_r( be, pdn, &matched );
if ( id2children_remove( be, p, e ) != 0 ) {
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "","" );
@ -93,9 +92,11 @@ ldbm_back_delete(
/* free entry and writer lock */
cache_return_entry_w( &li->li_cache, e );
if ( p )
if ( p != NULL )
cache_return_entry_r( &li->li_cache, p );
if ( matched != NULL ) free(matched);
send_ldap_result( conn, op, LDAP_SUCCESS, "", "" );
return( 0 );
@ -104,8 +105,10 @@ error_return:;
/* free entry and writer lock */
cache_return_entry_w( &li->li_cache, e );
if( p )
if( p != NULL )
cache_return_entry_r( &li->li_cache, p );
if ( matched != NULL ) free(matched);
return( -1 );
}

View File

@ -166,18 +166,19 @@ dn2entry(
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
ID id;
Entry *e;
Entry *e = NULL;
char *pdn;
Debug(LDAP_DEBUG_TRACE, "dn2entry_%s: dn: %s\n",
rw ? "w" : "r", dn, 0);
*matched = NULL;
if ( (id = dn2id( be, dn )) != NOID &&
(e = id2entry( be, id, rw )) != NULL )
{
return( e );
}
*matched = NULL;
/* stop when we get to the suffix */
if ( be_issuffix( be, dn ) ) {
@ -199,19 +200,6 @@ dn2entry(
return( NULL );
}
#if 0
if (e->e_state == ENTRY_STATE_DELETED)
continue;
if (strcmp(dn, e->e_dn) != 0)
continue;
/* return locked entry entry */
return(e);
}
}
#endif
Entry *
dn2entry_r(
Backend *be,

View File

@ -45,7 +45,8 @@ ldbm_back_group(
free(matched);
return( 1 );
}
Debug( LDAP_DEBUG_ARGS, "=> ldbm_back_group: found bdn: %s matched: %s\n", bdn, (matched ? matched : ""), 0 );
Debug( LDAP_DEBUG_ARGS, "=> ldbm_back_group: found bdn: %s\n", bdn, 0, 0 );
/* check for deleted */

View File

@ -25,7 +25,7 @@ ldbm_back_modify(
)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
char *matched = NULL;
char *matched;
Entry *e;
int i, err;
LDAPMod *mod;

View File

@ -49,7 +49,7 @@ ldbm_back_search(
ID id;
Entry *e;
Attribute *ref;
char *matched = NULL;
char *matched;
int rmaxsize, nrefs;
char *rbuf, *rcur, *r;
int nentries = 0;