diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-08-01 15:39:01 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-08-03 18:48:02 +1000 |
commit | 35b309fa0cac9341f364243b03ebfcc80f74198e (patch) | |
tree | b99fc49ec70be97a41289b3978db367fba63a769 /source4/auth/gensec/pygensec.c | |
parent | d3fe48ba48b25f359292ee96dbf5cecc0b0b16a3 (diff) | |
download | samba-35b309fa0cac9341f364243b03ebfcc80f74198e.tar.gz samba-35b309fa0cac9341f364243b03ebfcc80f74198e.tar.bz2 samba-35b309fa0cac9341f364243b03ebfcc80f74198e.zip |
gensec: clarify memory ownership for gensec_session_info() and gensec_session_key()
This is slightly less efficient, because we no longer keep a cache on
the gensec structures, but much clearer in terms of memory ownership.
Both gensec_session_info() and gensec_session_key() now take a mem_ctx
and put the result only on that context.
Some duplication of memory in the callers (who were rightly uncertain
about who was the rightful owner of the returned memory) has been
removed to compensate for the internal copy.
Andrew Bartlett
Diffstat (limited to 'source4/auth/gensec/pygensec.c')
-rw-r--r-- | source4/auth/gensec/pygensec.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/source4/auth/gensec/pygensec.c b/source4/auth/gensec/pygensec.c index 102836533c..6a69fd3f9d 100644 --- a/source4/auth/gensec/pygensec.c +++ b/source4/auth/gensec/pygensec.c @@ -257,6 +257,7 @@ static PyObject *py_gensec_set_credentials(PyObject *self, PyObject *args) static PyObject *py_gensec_session_info(PyObject *self) { + TALLOC_CTX *mem_ctx; NTSTATUS status; PyObject *py_session_info; struct gensec_security *security = py_talloc_get_type(self, struct gensec_security); @@ -265,7 +266,9 @@ static PyObject *py_gensec_session_info(PyObject *self) PyErr_SetString(PyExc_RuntimeError, "no mechanism selected"); return NULL; } - status = gensec_session_info(security, &info); + mem_ctx = talloc_new(NULL); + + status = gensec_session_info(security, mem_ctx, &info); if (NT_STATUS_IS_ERR(status)) { PyErr_SetNTSTATUS(status); return NULL; @@ -273,6 +276,7 @@ static PyObject *py_gensec_session_info(PyObject *self) py_session_info = py_return_ndr_struct("samba.dcerpc.auth", "session_info", info, info); + talloc_free(mem_ctx); return py_session_info; } |