s3: Simplify pdb_set_plaintext_passwd() by removing a redundant condition
authorVolker Lendecke <vl@samba.org>
Mon, 14 Dec 2009 17:50:38 +0000 (18:50 +0100)
committerMichael Adam <obnox@samba.org>
Thu, 7 Jan 2010 10:07:54 +0000 (11:07 +0100)
if (current_history_len != pwHistLen) {
     if (current_history_len < pwHistLen) {
     }
}

The second "if" is a bit pointless here

source3/passdb/pdb_get_set.c

index 968da9d8d149ade5692dd21a9341e358dd4913a6..f0c3fb193afe45bf7d82eb83b795a6103364d7aa 100644 (file)
@@ -1036,33 +1036,22 @@ bool pdb_set_plaintext_passwd(struct samu *sampass, const char *plaintext)
         */
        pwhistory = (uchar *)pdb_get_pw_history(sampass, &current_history_len);
 
-       if (current_history_len != pwHistLen) {
+       if (current_history_len < pwHistLen) {
                /*
-                * After closing and reopening struct samu the history
-                * values will sync up. We can't do this here.
+                * Ensure we have space for the needed history.
                 */
+               uchar *new_history = talloc_zero_array(
+                       sampass, uchar,
+                       pwHistLen*PW_HISTORY_ENTRY_LEN);
 
-               /*
-                * current_history_len > pwHistLen is not a problem -
-                * we have more history than we need.
-                */
-
-               if (current_history_len < pwHistLen) {
-                       /*
-                        * Ensure we have space for the needed history.
-                        */
-                       uchar *new_history = talloc_zero_array(
-                               sampass, uchar,
-                               pwHistLen*PW_HISTORY_ENTRY_LEN);
-                       if (!new_history) {
-                               return False;
-                       }
+               if (!new_history) {
+                       return False;
+               }
 
-                       memcpy(new_history, pwhistory,
-                              current_history_len*PW_HISTORY_ENTRY_LEN);
+               memcpy(new_history, pwhistory,
+                      current_history_len*PW_HISTORY_ENTRY_LEN);
 
-                       pwhistory = new_history;
-               }
+               pwhistory = new_history;
        }
 
        if (pwhistory && pwHistLen) {