From: Andrew Bartlett Date: Thu, 7 Dec 2023 02:50:43 +0000 (+1300) Subject: pycredentials: Properly check type in creds.set_nt_hash() and samr.encrypt_samr_passw... X-Git-Tag: talloc-2.4.2~428 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=40de90336506233994a57cbde7a107e26ffe22bf;p=thirdparty%2Fsamba.git pycredentials: Properly check type in creds.set_nt_hash() and samr.encrypt_samr_password() We should not be just doing a talloc type check, we should check the python type first. Signed-off-by: Andrew Bartlett Reviewed-by: Joseph Sutton --- diff --git a/auth/credentials/pycredentials.c b/auth/credentials/pycredentials.c index 8e7d8ae7b56..a27e02d1aa5 100644 --- a/auth/credentials/pycredentials.c +++ b/auth/credentials/pycredentials.c @@ -568,6 +568,11 @@ static PyObject *py_creds_set_nt_hash(PyObject *self, PyObject *args) } obt = _obt; + if (!py_check_dcerpc_type(py_cp, "samba.dcerpc.samr", "Password")) { + /* py_check_dcerpc_type sets TypeError */ + return NULL; + } + pwd = pytalloc_get_type(py_cp, struct samr_Password); if (pwd == NULL) { /* pytalloc_get_type sets TypeError */ @@ -1073,6 +1078,11 @@ static PyObject *py_creds_encrypt_samr_password(PyObject *self, return NULL; } + if (!py_check_dcerpc_type(py_cp, "samba.dcerpc.samr", "Password")) { + /* py_check_dcerpc_type sets TypeError */ + return NULL; + } + pwd = pytalloc_get_type(py_cp, struct samr_Password); if (pwd == NULL) { /* pytalloc_get_type sets TypeError */ diff --git a/auth/credentials/wscript_build b/auth/credentials/wscript_build index 7568554df4d..83c6e8ca5a0 100644 --- a/auth/credentials/wscript_build +++ b/auth/credentials/wscript_build @@ -27,12 +27,13 @@ bld.SAMBA_SUBSYSTEM('CREDENTIALS_CMDLINE', source='credentials_cmdline.c', deps='samba-credentials') +pyrpc_util = bld.pyembed_libname('pyrpc_util') pytalloc_util = bld.pyembed_libname('pytalloc-util') pyparam_util = bld.pyembed_libname('pyparam_util') bld.SAMBA_PYTHON('pycredentials', source='pycredentials.c', - public_deps='samba-credentials %s %s CREDENTIALS_CMDLINE CREDENTIALS_KRB5 CREDENTIALS_SECRETS' % (pytalloc_util, pyparam_util), + public_deps='samba-credentials %s %s %s CREDENTIALS_CMDLINE CREDENTIALS_KRB5 CREDENTIALS_SECRETS' % (pyrpc_util, pytalloc_util, pyparam_util), realname='samba/credentials.so' )