summaryrefslogtreecommitdiff
path: root/source4/auth/credentials
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-09-22 16:44:17 -0700
committerJelmer Vernooij <jelmer@samba.org>2010-09-22 17:48:24 -0700
commit1c3c9a483be6d63b8efb67bfd2c04ef9302ccce6 (patch)
tree173fbd8c50b007dee35491958dd31d5604a2da5e /source4/auth/credentials
parent5b10c82a5837073836fcf04152a6f032c98c93d1 (diff)
downloadsamba-1c3c9a483be6d63b8efb67bfd2c04ef9302ccce6.tar.gz
samba-1c3c9a483be6d63b8efb67bfd2c04ef9302ccce6.tar.bz2
samba-1c3c9a483be6d63b8efb67bfd2c04ef9302ccce6.zip
s4-param: Fix more memory leaks, invalid memory context.
Diffstat (limited to 'source4/auth/credentials')
-rw-r--r--source4/auth/credentials/pycredentials.c48
1 files changed, 38 insertions, 10 deletions
diff --git a/source4/auth/credentials/pycredentials.c b/source4/auth/credentials/pycredentials.c
index e1a74037ec..879d906d6f 100644
--- a/source4/auth/credentials/pycredentials.c
+++ b/source4/auth/credentials/pycredentials.c
@@ -207,6 +207,7 @@ static PyObject *py_creds_guess(py_talloc_Object *self, PyObject *args)
{
PyObject *py_lp_ctx = Py_None;
struct loadparm_context *lp_ctx;
+ TALLOC_CTX *mem_ctx;
struct cli_credentials *creds;
creds = PyCredentials_AsCliCredentials(self);
@@ -214,13 +215,21 @@ static PyObject *py_creds_guess(py_talloc_Object *self, PyObject *args)
if (!PyArg_ParseTuple(args, "|O", &py_lp_ctx))
return NULL;
- lp_ctx = lpcfg_from_py_object(NULL, py_lp_ctx);
- if (lp_ctx == NULL)
+ mem_ctx = talloc_new(NULL);
+ if (mem_ctx == NULL) {
+ PyErr_NoMemory();
return NULL;
+ }
+
+ lp_ctx = lpcfg_from_py_object(mem_ctx, py_lp_ctx);
+ if (lp_ctx == NULL) {
+ talloc_free(mem_ctx);
+ return NULL;
+ }
cli_credentials_guess(creds, lp_ctx);
- talloc_free(lp_ctx);
+ talloc_free(mem_ctx);
Py_RETURN_NONE;
}
@@ -231,18 +240,27 @@ static PyObject *py_creds_set_machine_account(py_talloc_Object *self, PyObject *
struct loadparm_context *lp_ctx;
NTSTATUS status;
struct cli_credentials *creds;
+ TALLOC_CTX *mem_ctx;
creds = PyCredentials_AsCliCredentials(self);
if (!PyArg_ParseTuple(args, "|O", &py_lp_ctx))
return NULL;
- lp_ctx = lpcfg_from_py_object(NULL, py_lp_ctx);
- if (lp_ctx == NULL)
+ mem_ctx = talloc_new(NULL);
+ if (mem_ctx == NULL) {
+ PyErr_NoMemory();
return NULL;
+ }
+
+ lp_ctx = lpcfg_from_py_object(mem_ctx, py_lp_ctx);
+ if (lp_ctx == NULL) {
+ talloc_free(mem_ctx);
+ return NULL;
+ }
status = cli_credentials_set_machine_account(creds, lp_ctx);
- talloc_free(lp_ctx);
+ talloc_free(mem_ctx);
PyErr_NTSTATUS_IS_ERR_RAISE(status);
@@ -278,29 +296,39 @@ static PyObject *py_creds_get_named_ccache(py_talloc_Object *self, PyObject *arg
int ret;
const char *error_string;
struct cli_credentials *creds;
+ TALLOC_CTX *mem_ctx;
creds = PyCredentials_AsCliCredentials(self);
if (!PyArg_ParseTuple(args, "|Os", &py_lp_ctx, &ccache_name))
return NULL;
- lp_ctx = lpcfg_from_py_object(NULL, py_lp_ctx); /* FIXME: leaky */
- if (lp_ctx == NULL)
+ mem_ctx = talloc_new(NULL);
+ if (mem_ctx == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+
+ lp_ctx = lpcfg_from_py_object(mem_ctx, py_lp_ctx);
+ if (lp_ctx == NULL) {
+ talloc_free(mem_ctx);
return NULL;
+ }
- event_ctx = tevent_context_init(NULL);
+ event_ctx = tevent_context_init(mem_ctx);
ret = cli_credentials_get_named_ccache(creds, event_ctx, lp_ctx,
ccache_name, &ccc, &error_string);
talloc_free(lp_ctx);
if (ret == 0) {
talloc_steal(ccc, event_ctx);
+ talloc_free(mem_ctx);
return PyCredentialCacheContainer_from_ccache_container(ccc);
}
PyErr_SetString(PyExc_RuntimeError, error_string?error_string:"NULL");
- talloc_free(event_ctx);
+ talloc_free(mem_ctx);
return NULL;
}