X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fsasl.c;h=45fe39a95c13143abc949a72fbe75783e3aca74d;hb=6387a3b6bfd835e3bf3075f0030a57739b82d995;hp=0b1e1285db6d2d4228eaa4d5bc1eeee78665661f;hpb=f897519d11b039518f5a9985be6b0f4ba5edbbea;p=openldap diff --git a/servers/slapd/sasl.c b/servers/slapd/sasl.c index 0b1e1285db..45fe39a95c 100644 --- a/servers/slapd/sasl.c +++ b/servers/slapd/sasl.c @@ -1532,6 +1532,10 @@ int slap_sasl_getdn( Connection *conn, Operation *op, char *id, int len, id ? ( *id ? id : "" ) : "NULL", len, 0 ); #endif + if ( !op ) { + op = conn->c_sasl_bindop; + } + dn->bv_val = NULL; dn->bv_len = 0; @@ -1559,7 +1563,7 @@ int slap_sasl_getdn( Connection *conn, Operation *op, char *id, int len, /* EXTERNAL DNs are already normalized */ do_norm = 0; is_dn = SET_DN; - ber_str2bv( id, len, 1, dn ); + ber_str2bv_x( id, len, 1, dn, op->o_tmpmemctx ); } else { /* convert to u: form */ @@ -1606,7 +1610,7 @@ int slap_sasl_getdn( Connection *conn, Operation *op, char *id, int len, /* Build the new dn */ c1 = dn->bv_val; - dn->bv_val = SLAP_MALLOC( len+1 ); + dn->bv_val = sl_malloc( len+1, op->o_tmpmemctx ); if( dn->bv_val == NULL ) { #ifdef NEW_LOGGING LDAP_LOG( TRANSPORT, ERR, @@ -1648,16 +1652,16 @@ int slap_sasl_getdn( Connection *conn, Operation *op, char *id, int len, /* Dup the DN in any case, so we don't risk * leaks or dangling pointers later, * and the DN value is '\0' terminated */ - ber_dupbv( &dn2, dn ); + ber_dupbv_x( &dn2, dn, op->o_tmpmemctx ); dn->bv_val = dn2.bv_val; } /* All strings are in DN form now. Normalize if needed. */ if ( do_norm ) { - rc = dnNormalize2( NULL, dn, &dn2 ); + rc = dnNormalize2( NULL, dn, &dn2, op->o_tmpmemctx ); /* User DNs were constructed above and must be freed now */ - ch_free( dn->bv_val ); + sl_free( dn->bv_val, op->o_tmpmemctx ); if ( rc != LDAP_SUCCESS ) { dn->bv_val = NULL; @@ -1667,14 +1671,10 @@ int slap_sasl_getdn( Connection *conn, Operation *op, char *id, int len, *dn = dn2; } - if ( !op ) { - op = conn->c_sasl_bindop; - } - /* Run thru regexp */ slap_sasl2dn( op, dn, &dn2 ); if( dn2.bv_val ) { - ch_free( dn->bv_val ); + sl_free( dn->bv_val, op->o_tmpmemctx ); *dn = dn2; #ifdef NEW_LOGGING LDAP_LOG( TRANSPORT, ENTRY,