s3: Simplify pdb_set_plaintext_passwd by using talloc_zero_array
authorVolker Lendecke <vl@samba.org>
Mon, 14 Dec 2009 17:43:03 +0000 (18:43 +0100)
committerMichael Adam <obnox@samba.org>
Thu, 7 Jan 2010 10:07:53 +0000 (11:07 +0100)
source3/passdb/pdb_get_set.c

index bea4c3278e00ba1e433828272a7f5734dc7f897c..149dde080206fc2f421efd480a8d7a83f8a55601 100644 (file)
@@ -1051,7 +1051,7 @@ bool pdb_set_plaintext_passwd(struct samu *sampass, const char *plaintext)
                        /*
                         * Ensure we have space for the needed history.
                         */
-                       uchar *new_history = talloc_array(
+                       uchar *new_history = talloc_zero_array(
                                sampass, uchar,
                                pwHistLen*PW_HISTORY_ENTRY_LEN);
                        if (!new_history) {
@@ -1063,10 +1063,7 @@ bool pdb_set_plaintext_passwd(struct samu *sampass, const char *plaintext)
                                memcpy(new_history, pwhistory,
                                       current_history_len*PW_HISTORY_ENTRY_LEN);
                        }
-                       /* Clearing out any extra space. */
-                       memset(&new_history[current_history_len*PW_HISTORY_ENTRY_LEN],
-                              '\0', (pwHistLen-current_history_len)*PW_HISTORY_ENTRY_LEN);
-                       /* Finally replace it. */
+
                        pwhistory = new_history;
                }
        }