summaryrefslogtreecommitdiff
path: root/lib/tdb
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2012-12-11 16:51:01 +0100
committerAndreas Schneider <asn@cryptomilk.org>2012-12-12 13:15:00 +0100
commit7f08365a28770fdcc1bb625d8a16d11d8f15c29a (patch)
treef5bee5aeba1c4eb19662e9a48167529c26b60cfb /lib/tdb
parentd07a964fe25caaf796449fda9beda600990be650 (diff)
downloadsamba-7f08365a28770fdcc1bb625d8a16d11d8f15c29a.tar.gz
samba-7f08365a28770fdcc1bb625d8a16d11d8f15c29a.tar.bz2
samba-7f08365a28770fdcc1bb625d8a16d11d8f15c29a.zip
tdb: Fix possible crash bugs in the python tdb code.
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! Reviewed-by: Simo Sorce <idra@samba.org> Reviewed-by: Jelmer Vernooij <jelmer@samba.org>
Diffstat (limited to 'lib/tdb')
-rw-r--r--lib/tdb/pytdb.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c
index ae0e6f808d..cf77a25274 100644
--- a/lib/tdb/pytdb.c
+++ b/lib/tdb/pytdb.c
@@ -164,7 +164,14 @@ 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) {
+ self->closed = true;
+ PyErr_SetObject(PyExc_RuntimeError,
+ Py_BuildValue("(i,s)",
+ TDB_ERR_IO,
+ "Failed to reopen database"));
+ return NULL;
+ }
Py_RETURN_NONE;
}
@@ -209,7 +216,13 @@ static PyObject *obj_close(PyTdbObject *self)
Py_RETURN_NONE;
ret = tdb_close(self->ctx);
self->closed = true;
- 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 close database"));
+ return NULL;
+ }
Py_RETURN_NONE;
}