]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
auth/credentials: Remove use of pytalloc_get_type() of NDR types in pycredentials
authorAndrew Bartlett <abartlet@samba.org>
Wed, 20 Mar 2024 01:42:31 +0000 (14:42 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 28 Mar 2024 01:50:41 +0000 (01:50 +0000)
This function is based on a flawed premise that the
pointer is a talloc context, but the second element
in an array and any element in a structure is not a
talloc context.

The type has already been checked above.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
auth/credentials/pycredentials.c

index a16be54690163e77a37cbd428ea6ba35f9d91562..5cdbe7796e68627a5d678565fbc382098457db6c 100644 (file)
@@ -574,11 +574,7 @@ static PyObject *py_creds_set_nt_hash(PyObject *self, PyObject *args)
                return NULL;
        }
 
-       pwd = pytalloc_get_type(py_cp, struct samr_Password);
-       if (pwd == NULL) {
-               /* pytalloc_get_type sets TypeError */
-               return NULL;
-       }
+       pwd = pytalloc_get_ptr(py_cp);
 
        return PyBool_FromLong(cli_credentials_set_nt_hash(creds, pwd, obt));
 }
@@ -1093,7 +1089,12 @@ static PyObject *py_creds_encrypt_netr_crypt_password(PyObject *self,
                return NULL;
        }
 
-       pwd = pytalloc_get_type(py_cp, struct netr_CryptPassword);
+       if (!py_check_dcerpc_type(py_cp, "samba.dcerpc.netlogon", "netr_CryptPassword")) {
+               /* py_check_dcerpc_type sets TypeError */
+               return NULL;
+       }
+
+       pwd = pytalloc_get_ptr(py_cp);
        if (pwd == NULL) {
                /* pytalloc_get_type sets TypeError */
                return NULL;