summaryrefslogtreecommitdiff
path: root/source4/auth
diff options
context:
space:
mode:
authorJoseph Sutton <josephsutton@catalyst.net.nz>2021-07-19 17:29:39 +1200
committerAndrew Bartlett <abartlet@samba.org>2021-08-18 22:28:33 +0000
commit814df05f8c10e9d82e6082d42ece1df569db4385 (patch)
tree70b56453ddc18d36e87ca7826ea173748a6522d4 /source4/auth
parent4809f4a6ee971bcd9767839c729b636b7582fc02 (diff)
downloadsamba-814df05f8c10e9d82e6082d42ece1df569db4385.tar.gz
pygensec: Fix memory leaks
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source4/auth')
-rw-r--r--source4/auth/gensec/pygensec.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/source4/auth/gensec/pygensec.c b/source4/auth/gensec/pygensec.c
index 490fcbecd58..f1f845a4663 100644
--- a/source4/auth/gensec/pygensec.c
+++ b/source4/auth/gensec/pygensec.c
@@ -310,9 +310,13 @@ static PyObject *py_gensec_session_info(PyObject *self,
return NULL;
}
mem_ctx = talloc_new(NULL);
+ if (mem_ctx == NULL) {
+ return PyErr_NoMemory();
+ }
status = gensec_session_info(security, mem_ctx, &info);
if (NT_STATUS_IS_ERR(status)) {
+ talloc_free(mem_ctx);
PyErr_SetNTSTATUS(status);
return NULL;
}
@@ -337,6 +341,9 @@ static PyObject *py_gensec_session_key(PyObject *self,
return NULL;
}
mem_ctx = talloc_new(NULL);
+ if (mem_ctx == NULL) {
+ return PyErr_NoMemory();
+ }
status = gensec_session_key(security, mem_ctx, &session_key);
if (!NT_STATUS_IS_OK(status)) {
@@ -466,7 +473,12 @@ static PyObject *py_gensec_update(PyObject *self, PyObject *args)
return NULL;
mem_ctx = talloc_new(NULL);
+ if (mem_ctx == NULL) {
+ return PyErr_NoMemory();
+ }
+
if (!PyBytes_Check(py_in)) {
+ talloc_free(mem_ctx);
PyErr_Format(PyExc_TypeError, "bytes expected");
return NULL;
}
@@ -510,8 +522,12 @@ static PyObject *py_gensec_wrap(PyObject *self, PyObject *args)
return NULL;
mem_ctx = talloc_new(NULL);
+ if (mem_ctx == NULL) {
+ return PyErr_NoMemory();
+ }
if (!PyBytes_Check(py_in)) {
+ talloc_free(mem_ctx);
PyErr_Format(PyExc_TypeError, "bytes expected");
return NULL;
}
@@ -545,8 +561,12 @@ static PyObject *py_gensec_unwrap(PyObject *self, PyObject *args)
return NULL;
mem_ctx = talloc_new(NULL);
+ if (mem_ctx == NULL) {
+ return PyErr_NoMemory();
+ }
if (!PyBytes_Check(py_in)) {
+ talloc_free(mem_ctx);
PyErr_Format(PyExc_TypeError, "bytes expected");
return NULL;
}
@@ -599,6 +619,9 @@ static PyObject *py_gensec_sign_packet(PyObject *self, PyObject *args)
pdu.length = pdu_length;
mem_ctx = talloc_new(NULL);
+ if (mem_ctx == NULL) {
+ return PyErr_NoMemory();
+ }
status = gensec_sign_packet(security, mem_ctx,
data.data, data.length,