X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fpasswd.c;h=5c4390c3379c56dbd75de4726378f48e44d0954f;hb=a17df0e810578d593808c6afeb0cdea55a65633c;hp=fee10439dd2f1af387073e6fef9010b262c5f333;hpb=7dcb68f6fa4bcdb3fbd883d9149ec4c23713d1c9;p=openldap diff --git a/servers/slapd/passwd.c b/servers/slapd/passwd.c index fee10439dd..5c4390c337 100644 --- a/servers/slapd/passwd.c +++ b/servers/slapd/passwd.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2005 The OpenLDAP Foundation. + * Copyright 1998-2006 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -54,8 +54,9 @@ int passwd_extop( slap_callback cb2 = { NULL, slap_replog_cb, NULL, NULL }; int i, nhash; char **hashes; - int rc; + int rc; BackendDB *op_be; + int freenewpw = 0; cb2.sc_next = &cb; @@ -84,7 +85,7 @@ int passwd_extop( qpw->rs_old.bv_val ? " old" : "", qpw->rs_new.bv_val ? " new" : "", 0 ); } else { - Statslog( LDAP_DEBUG_STATS, "%s PASSMOD %s%s\n", + Statslog( LDAP_DEBUG_STATS, "%s PASSMOD%s%s\n", op->o_log_prefix, qpw->rs_old.bv_val ? " old" : "", qpw->rs_new.bv_val ? " new" : "", 0, 0 ); @@ -183,6 +184,7 @@ int passwd_extop( slap_passwd_generate( &qpw->rs_new ); if ( qpw->rs_new.bv_len ) { rsp = slap_passwd_return( &qpw->rs_new ); + freenewpw = 1; } } if ( qpw->rs_new.bv_len == 0 ) { @@ -197,8 +199,13 @@ int passwd_extop( if ( op->o_bd->be_extended ) { rs->sr_err = op->o_bd->be_extended( op, rs ); if ( rs->sr_err != LDAP_UNWILLING_TO_PERFORM && - rs->sr_err != SLAP_CB_CONTINUE ) { + rs->sr_err != SLAP_CB_CONTINUE ) + { rc = rs->sr_err; + if ( rsp ) { + rs->sr_rspdata = rsp; + rsp = NULL; + } goto error_return; } } @@ -256,6 +263,7 @@ old_good: ml->sml_values[i].bv_val = NULL; ml->sml_nvalues = NULL; ml->sml_desc = slap_schema.si_ad_userPassword; + ml->sml_type = ml->sml_desc->ad_cname; ml->sml_op = LDAP_MOD_REPLACE; ml->sml_flags = 0; ml->sml_next = qpw->rs_mods; @@ -278,24 +286,29 @@ old_good: rs->sr_rspdata = rsp; } else if ( rsp ) { ber_bvfree( rsp ); + rsp = NULL; } op->o_tag = LDAP_REQ_EXTENDED; op->o_callback = sc; } - slap_mods_free( qpw->rs_mods, 1 ); - if ( rsp ) { - free( qpw->rs_new.bv_val ); - } rc = rs->sr_err; op->oq_extended = qext; error_return:; + if ( qpw->rs_mods ) { + slap_mods_free( qpw->rs_mods, 1 ); + } + if ( freenewpw ) { + free( qpw->rs_new.bv_val ); + } if ( !BER_BVISNULL( &op->o_req_dn ) ) { op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx ); + BER_BVZERO( &op->o_req_dn ); } if ( !BER_BVISNULL( &op->o_req_ndn ) ) { op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx ); + BER_BVZERO( &op->o_req_ndn ); } return rc;