[PATCH 1/2] tdb: Fix possible crash bugs in the python tdb code.
Andreas Schneider
asn at samba.org
Tue Dec 11 09:20:13 MST 2012
You can't call tdb_error() for tdb_reopen() or tdb_close(), both return
the error code of close(2) and not a TDB_ERROR!
Signed-off-by: Andreas Schneider <asn at samba.org>
---
lib/tdb/pytdb.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c
index ae0e6f8..942a50c 100644
--- a/lib/tdb/pytdb.c
+++ b/lib/tdb/pytdb.c
@@ -164,7 +164,13 @@ static PyObject *obj_reopen(PyTdbObject *self)
int ret;
PyErr_TDB_RAISE_IF_CLOSED(self);
ret = tdb_reopen(self->ctx);
- PyErr_TDB_ERROR_IS_ERR_RAISE(ret, self->ctx);
+ if (ret != 0) {
+ PyErr_SetObject(PyExc_RuntimeError,
+ Py_BuildValue("(i,s)",
+ TDB_ERR_IO,
+ "Failed to reopen database"));
+ return NULL;
+ }
Py_RETURN_NONE;
}
@@ -208,8 +214,14 @@ static PyObject *obj_close(PyTdbObject *self)
if (self->closed)
Py_RETURN_NONE;
ret = tdb_close(self->ctx);
+ if (ret != 0) {
+ PyErr_SetObject(PyExc_RuntimeError,
+ Py_BuildValue("(i,s)",
+ TDB_ERR_IO,
+ "Failed to close database"));
+ return NULL;
+ }
self->closed = true;
- PyErr_TDB_ERROR_IS_ERR_RAISE(ret, self->ctx);
Py_RETURN_NONE;
}
--
1.8.0.1
More information about the samba-technical
mailing list