summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-02-11 23:37:44 +1100
committerAndrew Tridgell <tridge@samba.org>2010-02-12 01:08:11 +1100
commit9ba0d105ccd5599987c17e2474ecfe8ac3547f1b (patch)
tree362778af43a865d5a9567a2d0a68fb071fc7c869
parent76a2e936a02ba99a474dd20822ed170787b55a45 (diff)
downloadsamba-9ba0d105ccd5599987c17e2474ecfe8ac3547f1b.tar.gz
samba-9ba0d105ccd5599987c17e2474ecfe8ac3547f1b.tar.bz2
samba-9ba0d105ccd5599987c17e2474ecfe8ac3547f1b.zip
s4-pyldb: null terminate string ldb message elements from python
We need to eventually get rid of ldb_msg_find_attr_as_string() (or add a mem_ctx to it), but meanwhile we have too many places that break if we don't add a nul to the end of ldb msg strings from python.
-rw-r--r--source4/lib/ldb/pyldb.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c
index a19768d41b..285373219f 100644
--- a/source4/lib/ldb/pyldb.c
+++ b/source4/lib/ldb/pyldb.c
@@ -1617,7 +1617,7 @@ struct ldb_message_element *PyObject_AsMessageElement(TALLOC_CTX *mem_ctx,
me->values = talloc_array(me, struct ldb_val, me->num_values);
me->values[0].length = PyString_Size(set_obj);
me->values[0].data = talloc_memdup(me,
- (uint8_t *)PyString_AsString(set_obj), me->values[0].length);
+ (uint8_t *)PyString_AsString(set_obj), me->values[0].length+1);
} else if (PySequence_Check(set_obj)) {
int i;
me->num_values = PySequence_Size(set_obj);
@@ -1627,7 +1627,7 @@ struct ldb_message_element *PyObject_AsMessageElement(TALLOC_CTX *mem_ctx,
me->values[i].length = PyString_Size(obj);
me->values[i].data = talloc_memdup(me,
- (uint8_t *)PyString_AsString(obj), me->values[i].length);
+ (uint8_t *)PyString_AsString(obj), me->values[i].length+1);
}
} else {
talloc_free(me);
@@ -1772,7 +1772,7 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb
el->values = talloc_array(el, struct ldb_val, 1);
el->values[0].length = PyString_Size(py_elements);
el->values[0].data = talloc_memdup(el,
- (uint8_t *)PyString_AsString(py_elements), el->values[0].length);
+ (uint8_t *)PyString_AsString(py_elements), el->values[0].length+1);
} else if (PySequence_Check(py_elements)) {
el->num_values = PySequence_Size(py_elements);
el->values = talloc_array(el, struct ldb_val, el->num_values);
@@ -1787,7 +1787,7 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb
}
el->values[i].length = PyString_Size(item);
el->values[i].data = talloc_memdup(el,
- (uint8_t *)PyString_AsString(item), el->values[i].length);
+ (uint8_t *)PyString_AsString(item), el->values[i].length+1);
}
} else {
PyErr_SetString(PyExc_TypeError,