summaryrefslogtreecommitdiff
path: root/lib/tdb
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-07-16 19:03:40 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-07-16 11:58:21 +0200
commita8e88332a394f4a4c3e43b496738008fba39d39f (patch)
tree21661b2280edb723b8e500f695c5387c0f900e77 /lib/tdb
parentdff29e4aee5f6adda32e5a0905d3c46e810feb27 (diff)
downloadsamba-a8e88332a394f4a4c3e43b496738008fba39d39f.tar.gz
samba-a8e88332a394f4a4c3e43b496738008fba39d39f.tar.bz2
samba-a8e88332a394f4a4c3e43b496738008fba39d39f.zip
pytdb: Check for errors parsing strings into TDB_DATA
The call to PyStringAsString() can raise an exception, and we want to return that rather than following a NULL pointer later. Andrew Bartlett
Diffstat (limited to 'lib/tdb')
-rw-r--r--lib/tdb/pytdb.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c
index 48927522f3..ca1c847fb5 100644
--- a/lib/tdb/pytdb.c
+++ b/lib/tdb/pytdb.c
@@ -189,6 +189,8 @@ static PyObject *obj_get(PyTdbObject *self, PyObject *args)
return NULL;
key = PyString_AsTDB_DATA(py_key);
+ if (!key.dptr)
+ return NULL;
return PyString_FromTDB_DATA(tdb_fetch(self->ctx, key));
}
@@ -202,7 +204,11 @@ static PyObject *obj_append(PyTdbObject *self, PyObject *args)
return NULL;
key = PyString_AsTDB_DATA(py_key);
+ if (!key.dptr)
+ return NULL;
data = PyString_AsTDB_DATA(py_data);
+ if (!data.dptr)
+ return NULL;
ret = tdb_append(self->ctx, key, data);
PyErr_TDB_ERROR_IS_ERR_RAISE(ret, self->ctx);
@@ -222,6 +228,8 @@ static PyObject *obj_nextkey(PyTdbObject *self, PyObject *args)
return NULL;
key = PyString_AsTDB_DATA(py_key);
+ if (!key.dptr)
+ return NULL;
return PyString_FromTDB_DATA(tdb_nextkey(self->ctx, key));
}
@@ -235,6 +243,8 @@ static PyObject *obj_delete(PyTdbObject *self, PyObject *args)
return NULL;
key = PyString_AsTDB_DATA(py_key);
+ if (!key.dptr)
+ return NULL;
ret = tdb_delete(self->ctx, key);
PyErr_TDB_ERROR_IS_ERR_RAISE(ret, self->ctx);
Py_RETURN_NONE;
@@ -249,6 +259,8 @@ static PyObject *obj_has_key(PyTdbObject *self, PyObject *args)
return NULL;
key = PyString_AsTDB_DATA(py_key);
+ if (!key.dptr)
+ return NULL;
ret = tdb_exists(self->ctx, key);
if (ret != TDB_ERR_NOEXIST) {
PyErr_TDB_ERROR_IS_ERR_RAISE(ret, self->ctx);
@@ -268,7 +280,11 @@ static PyObject *obj_store(PyTdbObject *self, PyObject *args)
return NULL;
key = PyString_AsTDB_DATA(py_key);
+ if (!key.dptr)
+ return NULL;
value = PyString_AsTDB_DATA(py_value);
+ if (!value.dptr)
+ return NULL;
ret = tdb_store(self->ctx, key, value, flag);
PyErr_TDB_ERROR_IS_ERR_RAISE(ret, self->ctx);