]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:passdb: Zero memory for plaintext_pw from 'struct samu'
authorPavel Filipenský <pfilipensky@samba.org>
Mon, 8 Aug 2022 12:30:24 +0000 (14:30 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 26 Aug 2022 07:59:32 +0000 (07:59 +0000)
Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/passdb/pdb_get_set.c
source3/passdb/py_passdb.c

index c506b1bfc2800d24b4e8b54f54bdaadf3e463995..13bea8d40a67b0d7c4634d95b3226669c1902785 100644 (file)
@@ -899,10 +899,9 @@ bool pdb_set_pw_history(struct samu *sampass, const uint8_t *pwd, uint32_t histo
 
 bool pdb_set_plaintext_pw_only(struct samu *sampass, const char *password, enum pdb_value_state flag)
 {
-       if (password) {
-               if (sampass->plaintext_pw!=NULL)
-                       memset(sampass->plaintext_pw,'\0',strlen(sampass->plaintext_pw)+1);
+       BURN_STR(sampass->plaintext_pw);
 
+       if (password != NULL) {
                sampass->plaintext_pw = talloc_strdup(sampass, password);
 
                if (!sampass->plaintext_pw) {
index f6fd50215f2d359a9db4bd618496ac8ab5fb12f6..2d5b2ab57052cb7ef822cbfb73419a6cca35a90f 100644 (file)
@@ -797,6 +797,8 @@ static PyObject *py_samu_get_plaintext_passwd(PyObject *obj, void *closure)
        }
 
        py_plaintext_pw = PyUnicode_FromString(plaintext_pw);
+
+       BURN_STR(discard_const_p(char, plaintext_pw));
        talloc_free(frame);
        return py_plaintext_pw;
 }