From: Pierangelo Masarati Date: Mon, 25 Jul 2005 20:50:03 +0000 (+0000) Subject: destroy limits at exit X-Git-Tag: OPENLDAP_AC_BP~200 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0de20c028f1bdbc126e06f5a49568eac0d5317c1;p=openldap destroy limits at exit --- diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 95ae72d782..6cb351feac 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -421,6 +421,7 @@ void backend_destroy_one( BackendDB *bd, int dynamic ) free( bd->be_rootpw.bv_val ); } acl_destroy( bd->be_acl, frontendDB->be_acl ); + limits_destroy( bd->be_limits ); if ( dynamic ) { free( bd ); } diff --git a/servers/slapd/limits.c b/servers/slapd/limits.c index eaa60ecb8b..691a116366 100644 --- a/servers/slapd/limits.c +++ b/servers/slapd/limits.c @@ -93,7 +93,7 @@ limits_get( switch ( style ) { case SLAP_LIMITS_EXACT: - if ( ndn->bv_len == 0 ) { + if ( BER_BVISEMPTY( ndn ) ) { break; } @@ -130,7 +130,7 @@ limits_get( case SLAP_LIMITS_CHILDREN: { size_t d; - if ( ndn->bv_len == 0 ) { + if ( BER_BVISEMPTY( ndn ) ) { break; } @@ -147,7 +147,7 @@ limits_get( } } else { /* check for unescaped rdn separator */ - if ( !DN_SEPARATOR( ndn->bv_val[d-1] ) ) { + if ( !DN_SEPARATOR( ndn->bv_val[d - 1] ) ) { break; } } @@ -180,7 +180,7 @@ limits_get( } case SLAP_LIMITS_REGEX: - if ( ndn->bv_len == 0 ) { + if ( BER_BVISEMPTY( ndn ) ) { break; } if ( regexec( &lm[0]->lm_regex, ndn->bv_val, @@ -194,7 +194,7 @@ limits_get( break; case SLAP_LIMITS_ANONYMOUS: - if ( ndn->bv_len == 0 ) { + if ( BER_BVISEMPTY( ndn ) ) { Debug( LDAP_DEBUG_TRACE, "<== limits_get: type=DN match=%s\n", limits2str( style ), 0, 0 ); *limit = &lm[0]->lm_limits; @@ -203,7 +203,7 @@ limits_get( break; case SLAP_LIMITS_USERS: - if ( ndn->bv_len != 0 ) { + if ( !BER_BVISEMPTY( ndn ) ) { *limit = &lm[0]->lm_limits; Debug( LDAP_DEBUG_TRACE, "<== limits_get: type=DN match=%s\n", limits2str( style ), 0, 0 ); @@ -271,8 +271,8 @@ limits_add( { int rc; struct berval bv; - bv.bv_val = (char *) pattern; - bv.bv_len = strlen( pattern ); + + ber_str2bv( pattern, 0, 0, &bv ); rc = dnNormalize( 0, NULL, NULL, &bv, &lm->lm_pat, NULL ); if ( rc != LDAP_SUCCESS ) { @@ -297,8 +297,7 @@ limits_add( case SLAP_LIMITS_USERS: case SLAP_LIMITS_ANY: lm->lm_flags = style | type; - lm->lm_pat.bv_val = NULL; - lm->lm_pat.bv_len = 0; + BER_BVZERO( &lm->lm_pat ); break; } @@ -1319,3 +1318,37 @@ limits_check( Operation *op, SlapReply *rs ) return 0; } +void +limits_destroy( + struct slap_limits **lm ) +{ + int i; + + if ( lm == NULL ) { + return; + } + + for ( i = 0; lm[ i ]; i++ ) { + switch ( lm[ i ]->lm_flags & SLAP_LIMITS_MASK ) { + case SLAP_LIMITS_REGEX: + regfree( &lm[ i ]->lm_regex ); + break; + + case SLAP_LIMITS_EXACT: + case SLAP_LIMITS_ONE: + case SLAP_LIMITS_SUBTREE: + case SLAP_LIMITS_CHILDREN: + if ( !BER_BVISNULL( &lm[ i ]->lm_pat ) ) { + ch_free( lm[ i ]->lm_pat.bv_val ); + } + break; + + default: + break; + } + + ch_free( lm[ i ] ); + } + + ch_free( lm ); +} diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 72823cb2c0..29c6d8f15c 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -914,6 +914,7 @@ LDAP_SLAPD_F (void) limits_unparse_one LDAP_P(( struct slap_limits_set *limit, int which, struct berval *bv )); LDAP_SLAPD_F (void) limits_unparse LDAP_P(( struct slap_limits *limit, struct berval *bv )); +LDAP_SLAPD_F (void) limits_destroy LDAP_P(( struct slap_limits **lm )); /* * lock.c