From: Stefan Metzmacher Date: Thu, 24 May 2018 14:16:19 +0000 (+0200) Subject: pysmbd: consitently use talloc_stackframe() for temporary memory X-Git-Tag: tevent-0.9.37~369 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7ef67df3f3f0df313c21cc123223633df3fa3ce7;p=thirdparty%2Fsamba.git pysmbd: consitently use talloc_stackframe() for temporary memory Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c index 592cdf73f0a..700ce78a773 100644 --- a/source3/smbd/pysmbd.c +++ b/source3/smbd/pysmbd.c @@ -580,28 +580,28 @@ static PyObject *py_smbd_get_nt_acl(PyObject *self, PyObject *args, PyObject *kw int security_info_wanted; PyObject *py_sd; struct security_descriptor *sd; - TALLOC_CTX *tmp_ctx = talloc_new(NULL); + TALLOC_CTX *frame = talloc_stackframe(); connection_struct *conn; NTSTATUS status; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "si|z", discard_const_p(char *, kwnames), &fname, &security_info_wanted, &service)) { - TALLOC_FREE(tmp_ctx); + TALLOC_FREE(frame); return NULL; } - conn = get_conn(tmp_ctx, service); + conn = get_conn(frame, service); if (!conn) { - TALLOC_FREE(tmp_ctx); + TALLOC_FREE(frame); return NULL; } - status = get_nt_acl_conn(tmp_ctx, fname, conn, security_info_wanted, &sd); + status = get_nt_acl_conn(frame, fname, conn, security_info_wanted, &sd); PyErr_NTSTATUS_IS_ERR_RAISE(status); py_sd = py_return_ndr_struct("samba.dcerpc.security", "descriptor", sd, sd); - TALLOC_FREE(tmp_ctx); + TALLOC_FREE(frame); return py_sd; } @@ -662,28 +662,20 @@ static PyObject *py_smbd_get_sys_acl(PyObject *self, PyObject *args, PyObject *k struct smb_acl_t *acl; int acl_type; TALLOC_CTX *frame = talloc_stackframe(); - TALLOC_CTX *tmp_ctx = talloc_new(NULL); connection_struct *conn; char *service = NULL; struct smb_filename *smb_fname = NULL; - if (!tmp_ctx) { - PyErr_NoMemory(); - return NULL; - } - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "si|z", discard_const_p(char *, kwnames), &fname, &acl_type, &service)) { TALLOC_FREE(frame); - TALLOC_FREE(tmp_ctx); return NULL; } conn = get_conn(frame, service); if (!conn) { TALLOC_FREE(frame); - TALLOC_FREE(tmp_ctx); return NULL; } @@ -692,20 +684,17 @@ static PyObject *py_smbd_get_sys_acl(PyObject *self, PyObject *args, PyObject *k lp_posix_pathnames()); if (smb_fname == NULL) { TALLOC_FREE(frame); - TALLOC_FREE(tmp_ctx); return NULL; } - acl = SMB_VFS_SYS_ACL_GET_FILE( conn, smb_fname, acl_type, tmp_ctx); + acl = SMB_VFS_SYS_ACL_GET_FILE( conn, smb_fname, acl_type, frame); if (!acl) { TALLOC_FREE(frame); - TALLOC_FREE(tmp_ctx); return PyErr_SetFromErrno(PyExc_OSError); } py_acl = py_return_ndr_struct("samba.dcerpc.smb_acl", "t", acl, acl); TALLOC_FREE(frame); - TALLOC_FREE(tmp_ctx); return py_acl; }