sasl_security_properties_t *secprops )
{
int i, j, l;
- char **props = ldap_str2charray( in, "," );
+ char **props;
unsigned sflags = 0;
int got_sflags = 0;
sasl_ssf_t max_ssf = 0;
unsigned maxbufsize = 0;
int got_maxbufsize = 0;
- if( props == NULL || secprops == NULL ) {
+ if( secprops == NULL ) {
+ return LDAP_PARAM_ERROR;
+ }
+ props = ldap_str2charray( in, "," );
+ if( props == NULL ) {
return LDAP_PARAM_ERROR;
}
if ( sprops[j].ival ) {
unsigned v;
char *next = NULL;
- if ( !isdigit( props[i][sprops[j].key.bv_len] )) continue;
+ if ( !isdigit( (unsigned char)props[i][sprops[j].key.bv_len] ))
+ continue;
v = strtoul( &props[i][sprops[j].key.bv_len], &next, 10 );
if ( next == &props[i][sprops[j].key.bv_len] || next[0] != '\0' ) continue;
switch( sprops[j].ival ) {
break;
}
if ( BER_BVISNULL( &sprops[j].key )) {
+ ldap_charray_free( props );
return LDAP_NOT_SUPPORTED;
}
}
{LDAP_CUP_UNSUPPORTED_SCHEME, N_("LCUP Unsupported Scheme")},
{LDAP_CUP_RELOAD_REQUIRED, N_("LCUP Reload Required")},
+#ifdef LDAP_X_TXN
+ {LDAP_X_TXN_SPECIFY_OKAY, N_("TXN specify okay")},
+ {LDAP_X_TXN_ID_INVALID, N_("TXN ID is invalid")},
+#endif
/* API ResultCodes */
{LDAP_SERVER_DOWN, N_("Can't contact LDAP server")},
#endif
/* Find the result, last msg in chain... */
lm = r->lm_chain_tail;
- if ((lm->lm_msgtype == LDAP_RES_SEARCH_ENTRY) ||
- (lm->lm_msgtype == LDAP_RES_SEARCH_REFERENCE) ||
- (lm->lm_msgtype == LDAP_RES_INTERMEDIATE)) {
- lm = NULL;
+ /* FIXME: either this is not possible (assert?)
+ * or it should be handled */
+ if ( lm != NULL ) {
+ switch ( lm->lm_msgtype ) {
+ case LDAP_RES_SEARCH_ENTRY:
+ case LDAP_RES_SEARCH_REFERENCE:
+ case LDAP_RES_INTERMEDIATE:
+ lm = NULL;
+ break;
+
+ default:
+ break;
+ }
}
if( lm == NULL ) {
ldap_int_hostname = NULL;
}
#endif
+#ifdef HAVE_CYRUS_SASL
+ if ( gopts->ldo_def_sasl_authcid ) {
+ LDAP_FREE( gopts->ldo_def_sasl_authcid );
+ gopts->ldo_def_sasl_authcid = NULL;
+ }
+#endif
}
/*
if( user == NULL ) user = getenv("LOGNAME");
if( user != NULL ) {
- gopts->ldo_def_sasl_authcid = user;
+ gopts->ldo_def_sasl_authcid = LDAP_STRDUP( user );
}
}
#endif
}
} return LDAP_OPT_SUCCESS;
- /* Only accessed from inside this function by ldap_set_rebind_proc() */
- case LDAP_OPT_REBIND_PROC: {
- lo->ldo_rebind_proc = (LDAP_REBIND_PROC *)invalue;
- } return LDAP_OPT_SUCCESS;
- case LDAP_OPT_REBIND_PARAMS: {
- lo->ldo_rebind_params = (void *)invalue;
- } return LDAP_OPT_SUCCESS;
-
- /* Only accessed from inside this function by ldap_set_nextref_proc() */
- case LDAP_OPT_NEXTREF_PROC: {
- lo->ldo_nextref_proc = (LDAP_NEXTREF_PROC *)invalue;
- } return LDAP_OPT_SUCCESS;
- case LDAP_OPT_NEXTREF_PARAMS: {
- lo->ldo_nextref_params = (void *)invalue;
- } return LDAP_OPT_SUCCESS;
- }
-
- if(invalue == NULL) {
- /* no place to set from */
- return LDAP_OPT_ERROR;
- }
-
- /* options which cannot withstand invalue == NULL */
-
- switch(option) {
- case LDAP_OPT_API_INFO:
- case LDAP_OPT_DESC:
- /* READ ONLY */
- break;
-
- case LDAP_OPT_DEREF:
- lo->ldo_deref = * (const int *) invalue;
- return LDAP_OPT_SUCCESS;
-
- case LDAP_OPT_SIZELIMIT:
- lo->ldo_sizelimit = * (const int *) invalue;
- return LDAP_OPT_SUCCESS;
-
- case LDAP_OPT_TIMELIMIT:
- lo->ldo_timelimit = * (const int *) invalue;
- return LDAP_OPT_SUCCESS;
-
- case LDAP_OPT_PROTOCOL_VERSION: {
- int vers = * (const int *) invalue;
- if (vers < LDAP_VERSION_MIN || vers > LDAP_VERSION_MAX) {
- /* not supported */
- break;
- }
- lo->ldo_version = vers;
- } return LDAP_OPT_SUCCESS;
-
-
case LDAP_OPT_HOST_NAME: {
const char *host = (const char *) invalue;
LDAPURLDesc *ludlist = NULL;
return rc;
}
+ /* Only accessed from inside this function by ldap_set_rebind_proc() */
+ case LDAP_OPT_REBIND_PROC: {
+ lo->ldo_rebind_proc = (LDAP_REBIND_PROC *)invalue;
+ } return LDAP_OPT_SUCCESS;
+ case LDAP_OPT_REBIND_PARAMS: {
+ lo->ldo_rebind_params = (void *)invalue;
+ } return LDAP_OPT_SUCCESS;
+
+ /* Only accessed from inside this function by ldap_set_nextref_proc() */
+ case LDAP_OPT_NEXTREF_PROC: {
+ lo->ldo_nextref_proc = (LDAP_NEXTREF_PROC *)invalue;
+ } return LDAP_OPT_SUCCESS;
+ case LDAP_OPT_NEXTREF_PARAMS: {
+ lo->ldo_nextref_params = (void *)invalue;
+ } return LDAP_OPT_SUCCESS;
+ }
+
+ if(invalue == NULL) {
+ /* no place to set from */
+ return LDAP_OPT_ERROR;
+ }
+
+ /* options which cannot withstand invalue == NULL */
+
+ switch(option) {
+ case LDAP_OPT_API_INFO:
+ case LDAP_OPT_DESC:
+ /* READ ONLY */
+ break;
+
+ case LDAP_OPT_DEREF:
+ lo->ldo_deref = * (const int *) invalue;
+ return LDAP_OPT_SUCCESS;
+
+ case LDAP_OPT_SIZELIMIT:
+ lo->ldo_sizelimit = * (const int *) invalue;
+ return LDAP_OPT_SUCCESS;
+
+ case LDAP_OPT_TIMELIMIT:
+ lo->ldo_timelimit = * (const int *) invalue;
+ return LDAP_OPT_SUCCESS;
+
+ case LDAP_OPT_PROTOCOL_VERSION: {
+ int vers = * (const int *) invalue;
+ if (vers < LDAP_VERSION_MIN || vers > LDAP_VERSION_MAX) {
+ /* not supported */
+ break;
+ }
+ lo->ldo_version = vers;
+ } return LDAP_OPT_SUCCESS;
+
case LDAP_OPT_ERROR_NUMBER: {
int err = * (const int *) invalue;
BerElement *ber,
ber_int_t msgid)
{
- LDAPURLDesc *servers;
int rc;
Debug( LDAP_DEBUG_TRACE, "ldap_send_initial_request\n", 0, 0, 0 );
0, 0, 0 );
}
- {
- /*
- * use of DNS is turned off or this is an X.500 DN...
- * use our default connection
- */
- servers = NULL;
- }
-
#ifdef LDAP_CONNECTIONLESS
if (LDAP_IS_UDP(ld)) {
if (msgtype == LDAP_REQ_BIND) {
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
rc = ldap_send_server_request( ld, ber, msgid, NULL,
- servers, NULL, NULL );
+ NULL, NULL, NULL );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
- if (servers)
- ldap_free_urllist(servers);
return(rc);
}
ldap_free_urldesc( srvfunc );
}
} else {
+ int msgid, rc;
+ struct berval passwd = BER_BVNULL;
+
savedefconn = ld->ld_defconn;
++lc->lconn_refcnt; /* avoid premature free */
ld->ld_defconn = lc;
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
#endif
- if ( ldap_bind_s( ld, "", "", LDAP_AUTH_SIMPLE ) != LDAP_SUCCESS ) {
+ rc = ldap_sasl_bind( ld, "", LDAP_SASL_SIMPLE, &passwd,
+ NULL, NULL, &msgid );
+ if ( rc != LDAP_SUCCESS ) {
err = -1;
+
+ } else {
+ for ( err = 1; err > 0; ) {
+ struct timeval tv = { 0, 100000 };
+ LDAPMessage *res = NULL;
+
+ switch ( ldap_result( ld, msgid, LDAP_MSG_ALL, &tv, &res ) ) {
+ case -1:
+ err = -1;
+ break;
+
+ case 0:
+#ifdef LDAP_R_COMPILE
+ ldap_pvt_thread_yield();
+#endif
+ break;
+
+ case LDAP_RES_BIND:
+ rc = ldap_parse_result( ld, res, &err, NULL, NULL, NULL, NULL, 1 );
+ if ( rc != LDAP_SUCCESS ) {
+ err = -1;
+
+ } else if ( err != LDAP_SUCCESS ) {
+ err = -1;
+ }
+ /* else err == LDAP_SUCCESS == 0 */
+ break;
+
+ default:
+ assert( 0 );
+ }
+ }
}
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex );
LDAPRequest *lp;
int looped = 0;
int len = srv->lud_dn ? strlen( srv->lud_dn ) : 0;
- for (lp = origreq; lp; ) {
+ for ( lp = origreq; lp; ) {
if ( lp->lr_conn == lc ) {
- if ( len == lp->lr_dn.bv_len ) {
- if ( len && strncmp( srv->lud_dn, lp->lr_dn.bv_val,
- len ))
- continue;
+ if ( len == lp->lr_dn.bv_len
+ && len
+ && strncmp( srv->lud_dn, lp->lr_dn.bv_val, len ) == 0 )
+ {
looped = 1;
break;
}
}
- if ( lp == origreq )
+ if ( lp == origreq ) {
lp = lp->lr_child;
- else
+ } else {
lp = lr->lr_refnext;
+ }
}
if ( looped ) {
ldap_free_urllist( srv );
continue;
}
- if( lc->lconn_rebind_inprogress) {
+ if ( lc->lconn_rebind_inprogress ) {
/* We are already chasing a referral or search reference and a
* bind on that connection is in progress. We must queue
* referrals on that connection, so we don't get a request
static int wait4msg LDAP_P(( LDAP *ld, ber_int_t msgid, int all, struct timeval *timeout,
LDAPMessage **result ));
static ber_tag_t try_read1msg LDAP_P(( LDAP *ld, ber_int_t msgid,
- int all, Sockbuf *sb, LDAPConn **lc, LDAPMessage **result ));
+ int all, LDAPConn **lc, LDAPMessage **result ));
static ber_tag_t build_result_ber LDAP_P(( LDAP *ld, BerElement **bp, LDAPRequest *lr ));
static void merge_error_info LDAP_P(( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ));
static LDAPMessage * chkResponseList LDAP_P(( LDAP *ld, int msgid, int all));
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
#endif
- rc = try_read1msg( ld, msgid, all, lc->lconn_sb,
- &lc, result );
+ rc = try_read1msg( ld, msgid, all, &lc, result );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_conn_mutex );
#endif
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
#endif
- rc = try_read1msg( ld, msgid, all,
- lc->lconn_sb, &lc, result );
+ rc = try_read1msg( ld, msgid, all, &lc, result );
if ( lc == NULL ) lc = nextlc;
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_conn_mutex );
LDAP *ld,
ber_int_t msgid,
int all,
- Sockbuf *sb,
LDAPConn **lcp,
LDAPMessage **result )
{
#ifdef LDAP_CONNECTIONLESS
if ( LDAP_IS_UDP(ld) ) {
struct sockaddr from;
- ber_int_sb_read(sb, &from, sizeof(struct sockaddr));
+ ber_int_sb_read( lc->lconn_sb, &from, sizeof(struct sockaddr) );
if (ld->ld_options.ldo_version == LDAP_VERSION2) isv2=1;
}
nextresp3:
#endif
- tag = ber_get_next( sb, &len, ber );
+ tag = ber_get_next( lc->lconn_sb, &len, ber );
if ( tag == LDAP_TAG_MESSAGE ) {
/*
* We read a complete message.
(void *)ld, (long) id, 0);
retry_ber:
ber_free( ber, 1 );
- if ( ber_sockbuf_ctrl( sb, LBER_SB_OPT_DATA_READY, NULL ) ) {
+ if ( ber_sockbuf_ctrl( lc->lconn_sb, LBER_SB_OPT_DATA_READY, NULL ) ) {
goto retry;
}
return( LDAP_MSG_X_KEEP_LOOKING ); /* continue looking */
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
- *lcp = NULL;
+ lc = *lcp = NULL;
}
}
}
* datagram, if the sockbuf is readable we still have data
* to parse.
*/
- ber = ldap_alloc_ber_with_options(ld);
- if (ber_sockbuf_ctrl(sb, LBER_SB_OPT_DATA_READY, NULL)) ok=1;
+ ber = ldap_alloc_ber_with_options( ld );
+ if ( ber_sockbuf_ctrl( lc->lconn_sb, LBER_SB_OPT_DATA_READY, NULL ) ) ok = 1;
}
/* set up response chain */
if ( tmp == NULL ) {
ld->ld_errno = LDAP_SUCCESS;
return( tag );
}
- if ( ber_sockbuf_ctrl( sb, LBER_SB_OPT_DATA_READY, NULL ) ) {
+ if ( lc && ber_sockbuf_ctrl( lc->lconn_sb, LBER_SB_OPT_DATA_READY, NULL ) ) {
goto retry;
}
return( LDAP_MSG_X_KEEP_LOOKING ); /* continue looking */
if ( !*extensions ) {
*extensions =
LDAP_CALLOC(2, sizeof(LDAPSchemaExtensionItem *));
- if ( !*extensions )
- return 1;
+ if ( !*extensions ) {
+ LDAP_FREE( ext );
+ return 1;
+ }
n = 0;
} else {
for ( n=0; (*extensions)[n] != NULL; n++ )
;
tmp = LDAP_REALLOC(*extensions,
(n+2)*sizeof(LDAPSchemaExtensionItem *));
- if ( !tmp )
+ if ( !tmp ) {
+ LDAP_FREE( ext );
return 1;
+ }
*extensions = tmp;
}
(*extensions)[n] = ext;
seen_obsolete = 1;
nf->nf_obsolete = LDAP_SCHEMA_YES;
parse_whsp(&ss);
+ } else if ( !strcasecmp(sval,"OC") ) {
+ LDAP_FREE(sval);
+ if ( seen_class ) {
+ *code = LDAP_SCHERR_DUPOPT;
+ *errp = ss;
+ ldap_nameform_free(nf);
+ return(NULL);
+ }
+ seen_class = 1;
+ nf->nf_objectclass = parse_woid(&ss,code);
+ if ( !nf->nf_objectclass ) {
+ *errp = ss;
+ ldap_nameform_free(nf);
+ return NULL;
+ }
} else if ( !strcasecmp(sval,"MUST") ) {
LDAP_FREE(sval);
if ( seen_must ) {
6 ) == 0 ) {
if ( file_read( tmp.mod_values[i] + 6,
bvals[i] ) < 0 ) {
+ free( bvals );
+ for ( i = 0; i<num; i++ )
+ free( result[ i ] );
+ free( result );
return( NULL );
}
} else {
LDAPControl **cctrls,
int *msgidp )
{
+#ifdef LDAP_EXOP_X_TURN
BerElement *turnvalber = NULL;
struct berval *turnvalp = NULL;
int rc;
turnvalp, sctrls, cctrls, msgidp );
ber_free( turnvalber, 1 );
return rc;
+#else
+ return LDAP_CONTROL_NOT_FOUND;
+#endif
}
int
LDAPControl **sctrls,
LDAPControl **cctrls )
{
+#ifdef LDAP_EXOP_X_TURN
BerElement *turnvalber = NULL;
struct berval *turnvalp = NULL;
int rc;
turnvalp, sctrls, cctrls, NULL, NULL );
ber_free( turnvalber, 1 );
return rc;
+#else
+ return LDAP_CONTROL_NOT_FOUND;
+#endif
}
next = lm->lm_next;
ldap_msgfree( lm );
}
+
+ if ( ld->ld_abandoned != NULL ) {
+ LDAP_FREE( ld->ld_abandoned );
+ ld->ld_abandoned = NULL;
+ }
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
#endif
ld->ld_referrals = NULL;
}
- if ( ld->ld_abandoned != NULL ) {
- LDAP_FREE( ld->ld_abandoned );
- ld->ld_abandoned = NULL;
- }
-
if ( ld->ld_selectinfo != NULL ) {
ldap_free_select_info( ld->ld_selectinfo );
ld->ld_selectinfo = NULL;
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_destroy( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_destroy( &ld->ld_res_mutex );
+ ldap_pvt_thread_mutex_destroy( &ld->ld_conn_mutex );
#endif
#ifndef NDEBUG
LDAP_TRASH(ld);
/* RFC 2396: unreserved alphanum */
default:
- if ( !isalnum( s[0] ) ) {
+ if ( !isalnum( (unsigned char) s[0] ) ) {
len += 3;
} else {
len++;
/* RFC 2396: unreserved alphanum */
default:
- if ( !isalnum( s[i] ) ) {
+ if ( !isalnum( (unsigned char) s[i] ) ) {
escape = 1;
}
break;
specs[i] = ludp->lud_host;
ludp->lud_host = p;
p = strchr( ludp->lud_host, ']' );
- if ( p == NULL )
+ if ( p == NULL ) {
+ LDAP_FREE(ludp);
+ ldap_charray_free(specs);
return LDAP_PARAM_ERROR;
+ }
*p++ = '\0';
if ( *p != ':' ) {
- if ( *p != '\0' )
+ if ( *p != '\0' ) {
+ LDAP_FREE(ludp);
+ ldap_charray_free(specs);
return LDAP_PARAM_ERROR;
+ }
p = NULL;
}
} else {
ldap_pvt_hex_unescape(p);
ludp->lud_port = strtol( p, &next, 10 );
if ( next == p || next[0] != '\0' ) {
+ LDAP_FREE(ludp);
+ ldap_charray_free(specs);
return LDAP_PARAM_ERROR;
}
}
wchar_t ch;
- /* If input ptr is NULL, treat it as empty string. */
- if (utf8str == NULL) utf8str = "";
+ /* If input ptr is NULL or empty... */
+ if (utf8str == NULL || !*utf8str) {
+ if ( wcstr )
+ *wcstr = 0;
+ return 0;
+ }
/* Examine next UTF-8 character. If output buffer is NULL, ignore count */
while ( *utf8str && (wcstr==NULL || wclen<count) ) {
rw = (struct ldap_int_thread_rdwr_s *) LDAP_CALLOC( 1,
sizeof( struct ldap_int_thread_rdwr_s ) );
+ if ( !rw )
+ return LDAP_NO_MEMORY;
/* we should check return results */
ldap_pvt_thread_mutex_init( &rw->ltrw_mutex );
#endif
return 0;
#elif HAVE_THR_YIELD
- return thr_yield();
+ thr_yield();
+ return 0;
#elif HAVE_PTHREADS == 10
return sched_yield();
ldap_pvt_thread_pool_destroy ( ldap_pvt_thread_pool_t *tpool, int run_pending )
{
struct ldap_int_thread_pool_s *pool, *pptr;
- long waiting;
ldap_int_thread_ctx_t *ctx;
if (tpool == NULL)
l1 = ulen;
ucs = malloc( l2 * sizeof(*ucs) );
if ( ucs == NULL ) {
+ free( ucsout1 );
return l1 > l2 ? 1 : -1; /* what to do??? */
}
} else {
ber_len_t i;
for ( i = 0; val[i]; i++ ) {
- if ( !isascii( val[i] ) || !isprint( val[i] ) ) {
+ if ( !isascii( val[i] ) || !isprint( (unsigned char) val[i] ) ) {
return 1;
}
}
}
ptr = line + STRLENOF("include:");
- while (isspace(*ptr)) ptr++;
+ while (isspace((unsigned char) *ptr)) ptr++;
fp2 = ldif_open_url( ptr );
if ( fp2 ) {
LDIFFP *lnew = ber_memalloc( sizeof( LDIFFP ));
unsigned i, fracs;
/* Is the stamp reasonably long? */
- for (i=0; isdigit(atm[i]); i++);
+ for (i=0; isdigit((unsigned char) atm[i]); i++);
if (i < sizeof("00000101000000")-1)
break;
if (tm->tm_sec < 0 || tm->tm_sec > 61) break;
/* Fractions of seconds */
- for (i = 0, fracs = 0;isdigit(*ptr);) {
+ for (i = 0, fracs = 0; isdigit((unsigned char) *ptr); ) {
i*=10; i+= *ptr++ - '0';
fracs++;
}
* Error
*/
} else {
+ free( map );
Debug( LDAP_DEBUG_ANY, "[%s:%d] unknown map type\n%s",
fname, lineno, "" );
return -1;
return 0;
}
+static void
+destroy_actions(
+ struct rewrite_action *paction
+)
+{
+ struct rewrite_action *next;
+
+ for (; paction; paction = next) {
+ next = paction->la_next;
+ destroy_action( &paction );
+ }
+}
+
/*
- * In case of error it returns NULL and does not free all the memory
- * it allocated; as this is a once only phase, and an error at this stage
- * would require the server to stop, there is no need to be paranoid
- * about memory allocation
*/
int
rewrite_rule_compile(
*/
action = calloc( sizeof( struct rewrite_action ), 1 );
if ( action == NULL ) {
- /* cleanup ... */
- return REWRITE_ERR;
+ goto fail;
}
action->la_type = REWRITE_ACTION_STOP;
*/
action = calloc( sizeof( struct rewrite_action ), 1 );
if ( action == NULL ) {
- /* cleanup ... */
- return REWRITE_ERR;
+ goto fail;
}
mode &= ~REWRITE_RECURSE;
int *d;
if ( p[ 1 ] != '{' ) {
- /* XXX Need to free stuff */
- return REWRITE_ERR;
+ goto fail;
}
d = malloc( sizeof( int ) );
if ( d == NULL ) {
- /* XXX Need to free stuff */
- return REWRITE_ERR;
+ goto fail;
}
d[ 0 ] = strtol( &p[ 2 ], &next, 0 );
if ( next == &p[ 2 ] || next[0] != '}' ) {
- /* XXX Need to free stuff */
- return REWRITE_ERR;
+ free( d );
+ goto fail;
}
action = calloc( sizeof( struct rewrite_action ), 1 );
if ( action == NULL ) {
- /* cleanup ... */
- return REWRITE_ERR;
+ free( d );
+ goto fail;
}
switch ( p[ 0 ] ) {
case REWRITE_FLAG_GOTO:
char *next = NULL;
if ( p[ 1 ] != '{' ) {
- /* XXX Need to free stuff */
- return REWRITE_ERR;
+ goto fail;
}
max_passes = strtol( &p[ 2 ], &next, 0 );
if ( next == &p[ 2 ] || next[0] != '}' ) {
- /* XXX Need to free stuff */
- return REWRITE_ERR;
+ goto fail;
}
if ( max_passes < 1 ) {
*/
action = calloc( sizeof( struct rewrite_action ), 1 );
if ( action == NULL ) {
- /* cleanup ... */
- return REWRITE_ERR;
+ goto fail;
}
action->la_type = REWRITE_ACTION_IGNORE_ERR;
*/
rule = calloc( sizeof( struct rewrite_rule ), 1 );
if ( rule == NULL ) {
- /* charray_free( res ); */
- /*
- * XXX need to free the value subst stuff!
- */
- return REWRITE_ERR;
+ goto fail;
}
/*
* REGEX compilation (luckily I don't need to take care of this ...)
*/
if ( regcomp( &rule->lr_regex, ( char * )pattern, flags ) != 0 ) {
- /* charray_free( res ); */
- /*
- *XXX need to free the value subst stuff!
- */
free( rule );
- return REWRITE_ERR;
+ goto fail;
}
/*
append_rule( context, rule );
return REWRITE_SUCCESS;
+
+fail:
+ destroy_actions( first_action );
+ free( subst );
+ return REWRITE_ERR;
}
/*
)
{
struct rewrite_rule *rule;
- struct rewrite_action *action;
assert( prule != NULL );
assert( *prule != NULL );
regfree( &rule->lr_regex );
- for ( action = rule->lr_action; action; ) {
- struct rewrite_action *curraction = action;
-
- action = action->la_next;
- destroy_action( &curraction );
- }
+ destroy_actions( rule->lr_action );
free( rule );
*prule = NULL;
static void
rewrite_session_free( void *v_session )
{
+ struct rewrite_session *session = (struct rewrite_session *)v_session;
+
+ ldap_pvt_thread_mutex_lock( &session->ls_mutex );
rewrite_session_clean( v_session );
free( v_session );
}
/* Unhandled map */
}
-
+
+ free( map );
return NULL;
}