From: Noel Power Date: Tue, 6 Mar 2018 15:03:13 +0000 (+0000) Subject: s4/ntvfs/posix/python: python3 (get|set)xattr value should be bytes X-Git-Url: http://git.samba.org/?p=metze%2Fsamba%2Fwip.git;a=commitdiff_plain;h=c10925e9507f8810f3ba91ac51454357a6c67c8f s4/ntvfs/posix/python: python3 (get|set)xattr value should be bytes Signed-off-by: Noel Power Reviewed-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- diff --git a/source4/ntvfs/posix/python/pyposix_eadb.c b/source4/ntvfs/posix/python/pyposix_eadb.c index d43c7c47bb79..646498225b39 100644 --- a/source4/ntvfs/posix/python/pyposix_eadb.c +++ b/source4/ntvfs/posix/python/pyposix_eadb.c @@ -43,7 +43,7 @@ static PyObject *py_wrap_setxattr(PyObject *self, PyObject *args) TALLOC_CTX *mem_ctx; struct tdb_wrap *eadb; - if (!PyArg_ParseTuple(args, "ssss#", &tdbname, &filename, &attribute, + if (!PyArg_ParseTuple(args, "sss"PYARG_BYTES_LEN, &tdbname, &filename, &attribute, &blob.data, &blobsize)) return NULL; @@ -101,7 +101,7 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args) talloc_free(mem_ctx); return NULL; } - ret = PyStr_FromStringAndSize((char *)blob.data, blob.length); + ret = Py_BuildValue(PYARG_BYTES_LEN, blob.data, blob.length); talloc_free(mem_ctx); return ret; } diff --git a/source4/ntvfs/posix/python/pyxattr_native.c b/source4/ntvfs/posix/python/pyxattr_native.c index c5e740fe577a..b1fa2a208e54 100644 --- a/source4/ntvfs/posix/python/pyxattr_native.c +++ b/source4/ntvfs/posix/python/pyxattr_native.c @@ -41,7 +41,7 @@ static PyObject *py_wrap_setxattr(PyObject *self, PyObject *args) Py_ssize_t blobsize; DATA_BLOB blob; - if (!PyArg_ParseTuple(args, "sss#", &filename, &attribute, &blob.data, + if (!PyArg_ParseTuple(args, "ss"PYARG_BYTES_LEN, &filename, &attribute, &blob.data, &blobsize)) return NULL; @@ -90,7 +90,7 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args) talloc_free(mem_ctx); return NULL; } - ret = PyStr_FromStringAndSize(buf, len); + ret = Py_BuildValue(PYARG_BYTES_LEN, buf, len); talloc_free(mem_ctx); return ret; } diff --git a/source4/ntvfs/posix/python/pyxattr_tdb.c b/source4/ntvfs/posix/python/pyxattr_tdb.c index 05303b6aa00a..f9a1fa5fd80c 100644 --- a/source4/ntvfs/posix/python/pyxattr_tdb.c +++ b/source4/ntvfs/posix/python/pyxattr_tdb.c @@ -50,7 +50,7 @@ static PyObject *py_wrap_setxattr(PyObject *self, PyObject *args) struct file_id id; struct stat sbuf; - if (!PyArg_ParseTuple(args, "ssss#", &tdbname, &filename, &attribute, + if (!PyArg_ParseTuple(args, "sss"PYARG_BYTES_LEN, &tdbname, &filename, &attribute, &blob.data, &blobsize)) return NULL; @@ -137,7 +137,7 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args) talloc_free(mem_ctx); return NULL; } - ret_obj = PyStr_FromStringAndSize((char *)blob.data, xattr_size); + ret_obj = Py_BuildValue(PYARG_BYTES_LEN, blob.data, xattr_size); talloc_free(mem_ctx); return ret_obj; }