Blob Blame Raw
From 7345c51c68dfd90a704ccbb0e5b1e736af80f146 Mon Sep 17 00:00:00 2001
From: Thierry Bordaz <tbordaz@redhat.com>
Date: Mon, 17 May 2021 16:10:22 +0200
Subject: [PATCH] Issue 4725 - Fix compiler warnings

---
 ldap/servers/slapd/proto-slap.h | 2 +-
 ldap/servers/slapd/pw.c         | 9 ++++-----
 ldap/servers/slapd/pw_retry.c   | 2 --
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 6ff178127..2768d5a1d 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -1012,7 +1012,7 @@ int add_shadow_ext_password_attrs(Slapi_PBlock *pb, Slapi_Entry **e);
  * pw_retry.c
  */
 int update_pw_retry(Slapi_PBlock *pb);
-int update_trp_pw_usecount(Slapi_PBlock *pb, Slapi_Entry *e, int32_t use_count);
+int update_tpr_pw_usecount(Slapi_PBlock *pb, Slapi_Entry *e, int32_t use_count);
 void pw_apply_mods(const Slapi_DN *sdn, Slapi_Mods *mods);
 void pw_set_componentID(struct slapi_componentid *cid);
 struct slapi_componentid *pw_get_componentID(void);
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index d98422513..2a167c8f1 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -2622,7 +2622,6 @@ int
 slapi_check_tpr_limits(Slapi_PBlock *pb, Slapi_Entry *bind_target_entry, int send_result) {
     passwdPolicy *pwpolicy = NULL;
     char *dn = NULL;
-    int tpr_maxuse;
     char *value;
     time_t cur_time;
     char *cur_time_str = NULL;
@@ -2638,7 +2637,7 @@ slapi_check_tpr_limits(Slapi_PBlock *pb, Slapi_Entry *bind_target_entry, int sen
         return 0;
     }
 
-    if (slapi_entry_attr_hasvalue(bind_target_entry, "pwdTPRReset", "TRUE") == NULL) {
+    if (!slapi_entry_attr_hasvalue(bind_target_entry, "pwdTPRReset", "TRUE")) {
         /* the password was not reset by an admin while a TRP pwp was set, just returned */
         return 0;
     }
@@ -2646,7 +2645,7 @@ slapi_check_tpr_limits(Slapi_PBlock *pb, Slapi_Entry *bind_target_entry, int sen
     /* Check entry TPR max use */
     if (pwpolicy->pw_tpr_maxuse >= 0) {
         uint use_count;
-        value = slapi_entry_attr_get_ref(bind_target_entry, "pwdTPRUseCount");
+        value = (char *) slapi_entry_attr_get_ref(bind_target_entry, "pwdTPRUseCount");
         if (value) {
             /* max Use is enforced */
             use_count = strtoull(value, 0, 0);
@@ -2681,7 +2680,7 @@ slapi_check_tpr_limits(Slapi_PBlock *pb, Slapi_Entry *bind_target_entry, int sen
 
     /* Check entry TPR expiration at a specific time */
     if (pwpolicy->pw_tpr_delay_expire_at >= 0) {
-        value = slapi_entry_attr_get_ref(bind_target_entry, "pwdTPRExpireAt");
+        value = (char *) slapi_entry_attr_get_ref(bind_target_entry, "pwdTPRExpireAt");
         if (value) {
             /* max Use is enforced */
             if (difftime(parse_genTime(cur_time_str), parse_genTime(value)) >= 0) {
@@ -2709,7 +2708,7 @@ slapi_check_tpr_limits(Slapi_PBlock *pb, Slapi_Entry *bind_target_entry, int sen
 
     /* Check entry TPR valid after a specific time */
     if (pwpolicy->pw_tpr_delay_valid_from >= 0) {
-        value = slapi_entry_attr_get_ref(bind_target_entry, "pwdTPRValidFrom");
+        value = (char *) slapi_entry_attr_get_ref(bind_target_entry, "pwdTPRValidFrom");
         if (value) {
             /* validity after a specific time is enforced */
             if (difftime(parse_genTime(value), parse_genTime(cur_time_str)) >= 0) {
diff --git a/ldap/servers/slapd/pw_retry.c b/ldap/servers/slapd/pw_retry.c
index 5d13eb636..af54aa19d 100644
--- a/ldap/servers/slapd/pw_retry.c
+++ b/ldap/servers/slapd/pw_retry.c
@@ -163,8 +163,6 @@ set_retry_cnt_and_time(Slapi_PBlock *pb, int count, time_t cur_time)
 int
 set_tpr_usecount_mods(Slapi_PBlock *pb, Slapi_Mods *smods, int count)
 {
-    char *timestr;
-    time_t unlock_time;
     char retry_cnt[16] = {0}; /* 1-65535 */
     const char *dn = NULL;
     Slapi_DN *sdn = NULL;
-- 
2.31.1