summaryrefslogtreecommitdiff
path: root/source4/librpc
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2010-11-30 15:59:04 +1100
committerAndrew Bartlett <abartlet@samba.org>2010-12-01 00:14:40 +0100
commit4ea840c3a50557a5c084694d5d30fc3d0532f4ff (patch)
treea9c567d949114df7d4c5116bffbbd2f623632982 /source4/librpc
parent2b0905aeaecdc7fabad5661b4c726500f613be39 (diff)
downloadsamba-4ea840c3a50557a5c084694d5d30fc3d0532f4ff.tar.gz
samba-4ea840c3a50557a5c084694d5d30fc3d0532f4ff.tar.bz2
samba-4ea840c3a50557a5c084694d5d30fc3d0532f4ff.zip
s4-librpc Handle all types of GUID in the GUID() initialiser
By taking a length-limited string, we can parse binary and string GUID values, which is particularly useful when reading from ldb. Andrew Bartlett
Diffstat (limited to 'source4/librpc')
-rw-r--r--source4/librpc/ndr/py_misc.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/source4/librpc/ndr/py_misc.c b/source4/librpc/ndr/py_misc.c
index 5d5b881b38..184029b59b 100644
--- a/source4/librpc/ndr/py_misc.c
+++ b/source4/librpc/ndr/py_misc.c
@@ -61,16 +61,24 @@ static PyObject *py_GUID_repr(PyObject *py_self)
static int py_GUID_init(PyObject *self, PyObject *args, PyObject *kwargs)
{
- char *str = NULL;
+ PyObject *str = NULL;
NTSTATUS status;
struct GUID *guid = py_talloc_get_ptr(self);
const char *kwnames[] = { "str", NULL };
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s", discard_const_p(char *, kwnames), &str))
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", discard_const_p(char *, kwnames), &str))
return -1;
if (str != NULL) {
- status = GUID_from_string(str, guid);
+ DATA_BLOB guid_val;
+
+ if (!PyString_Check(str)) {
+ PyErr_SetString(PyExc_TypeError, "Expected a string argument to GUID()");
+ return -1;
+ }
+ guid_val.data = (uint8_t *)PyString_AsString(str);
+ guid_val.length = PyString_Size(str);
+ status = GUID_from_data_blob(&guid_val, guid);
if (!NT_STATUS_IS_OK(status)) {
PyErr_SetNTSTATUS(status);
return -1;