1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

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 <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
This commit is contained in:
Andrew Bartlett 2023-12-07 15:50:43 +13:00
parent 00034d0228
commit 40de903365
2 changed files with 12 additions and 1 deletions

View File

@ -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 */

View File

@ -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'
)