zrhoffman / rpms / 389-ds-base

Forked from rpms/389-ds-base 3 years ago
Clone

Blame SOURCES/0052-Ticket-48228-wrong-password-check-if-passwordInHisto.patch

a2f18f
From 679e7b024e36ac9dfce85766f5d82cc272911e53 Mon Sep 17 00:00:00 2001
a2f18f
From: Noriko Hosoi <nhosoi@redhat.com>
a2f18f
Date: Tue, 25 Aug 2015 16:31:10 -0700
a2f18f
Subject: [PATCH 52/52] Ticket #48228 - wrong password check if
a2f18f
 passwordInHistory is decreased.
a2f18f
a2f18f
Description: Regression was added by this commit:
a2f18f
  commit 1a119125856006543aae0520b5800a8b52c3b049
a2f18f
  Ticket #48228 - wrong password check if passwordInHistory is decreased.
a2f18f
Compare function pw_history_cmp used in qsort did not check the correct
a2f18f
address for the timestamp string, which made qsort return the password
a2f18f
history in the wrong order.
a2f18f
a2f18f
https://fedorahosted.org/389/ticket/48228
a2f18f
a2f18f
Reviewed by rmeggins@redhat.com (Thank you, Rich!)
a2f18f
a2f18f
(cherry picked from commit 391acfcf9a67b9b27ebbd98d1dfe30ef54a027c4)
a2f18f
(cherry picked from commit 096b386663c949136095def77a7fb12eee64e542)
a2f18f
---
a2f18f
 ldap/servers/slapd/pw.c | 21 ++++++++-------------
a2f18f
 1 file changed, 8 insertions(+), 13 deletions(-)
a2f18f
a2f18f
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
a2f18f
index 3abebbf..4e222d7 100644
a2f18f
--- a/ldap/servers/slapd/pw.c
a2f18f
+++ b/ldap/servers/slapd/pw.c
a2f18f
@@ -1085,8 +1085,6 @@ retry:
a2f18f
 static int
a2f18f
 pw_history_cmp(const void *h0, const void *h1)
a2f18f
 {
a2f18f
-	size_t h0sz = 0;
a2f18f
-	size_t h1sz = 0;
a2f18f
 	if (!h0) {
a2f18f
 		if (!h1) {
a2f18f
 			return 0;
a2f18f
@@ -1097,23 +1095,20 @@ pw_history_cmp(const void *h0, const void *h1)
a2f18f
 		if (!h1) {
a2f18f
 			return 1;
a2f18f
 		} else {
a2f18f
-			size_t delta;
a2f18f
-			h0sz = strlen(h0);
a2f18f
-			h1sz = strlen(h1);
a2f18f
-			delta = h0sz - h1sz;
a2f18f
-			if (!delta) {
a2f18f
-				return delta;
a2f18f
-			}
a2f18f
-			if (h0sz < GENERALIZED_TIME_LENGTH) {
a2f18f
+			char *h0str = *(char **)h0;
a2f18f
+			char *h1str = *(char **)h1;
a2f18f
+			size_t h0sz = strlen(h0str);
a2f18f
+			size_t h1sz = strlen(h1str);
a2f18f
+			if ((h0sz < GENERALIZED_TIME_LENGTH) ||
a2f18f
+			    (h1sz < GENERALIZED_TIME_LENGTH)) {
a2f18f
 				/* too short for the history str. */
a2f18f
-				return 0;
a2f18f
+				return h0sz - h1sz;
a2f18f
 			}
a2f18f
+			return PL_strncmp(h0str, h1str, GENERALIZED_TIME_LENGTH);
a2f18f
 		}
a2f18f
 	}
a2f18f
-	return PL_strncmp(h0, h1, GENERALIZED_TIME_LENGTH);
a2f18f
 }
a2f18f
 
a2f18f
-
a2f18f
 static int
a2f18f
 update_pw_history( Slapi_PBlock *pb, const Slapi_DN *sdn, char *old_pw )
a2f18f
 {
a2f18f
-- 
a2f18f
1.9.3
a2f18f