pwd-plugin: Remove the correct password from the history

We were mistakenly removeing the latest password from the passwordHistory
once the max history values were reached. Make sure we remove the oldest one
instead.
This commit is contained in:
Simo Sorce 2010-10-04 16:25:26 -04:00
parent 9cd0330e5d
commit 6682b63438

View File

@ -1293,7 +1293,7 @@ Slapi_Value **ipapwd_setPasswordHistory(Slapi_Mods *smods,
ret = slapi_entry_attr_find(data->target,
"passwordHistory", &passwordHistory);
if (ret == 0) {
int ret, hint, count, i;
int ret, hint, count, i, j;
const char *pwstr;
Slapi_Value *pw;
@ -1327,6 +1327,11 @@ Slapi_Value **ipapwd_setPasswordHistory(Slapi_Mods *smods,
qsort(pH, i, sizeof(Slapi_Value *), ipapwd_sv_pw_cmp);
if (i >= data->pwHistoryLen) {
/* need to rotate out the first entry */
for (j = 0; j < data->pwHistoryLen; j++) {
pH[j] = pH[j + 1];
}
i = data->pwHistoryLen;
pH[i] = NULL;
i--;