This is an automated email from the git hooks/post-receive script.
nsoffer pushed a commit to branch master
in repository sanlock.
commit 0a130d251ee01ae1c062a92a534d008216c8c619
Author: Amit Bawer <abawer(a)redhat.com>
AuthorDate: Sun Jun 2 16:42:04 2019 +0300
python: Use PyBytes converter for rem_lockspace API
Implications:
- Py2 : no difference
- Py3 : if used, only accept bytes for lockspace name.
---
python/sanlock.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/python/sanlock.c b/python/sanlock.c
index 1fdb143..28146df 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -855,8 +855,9 @@ successful termination these leases will be released.");
static PyObject *
py_rem_lockspace(PyObject *self __unused, PyObject *args, PyObject *keywds)
{
- int rv, async = 0, unused = 0, flags = 0;
- const char *lockspace, *path;
+ int rv = -1, async = 0, unused = 0, flags = 0;
+ PyObject *lockspace = NULL;
+ const char *path;
struct sanlk_lockspace ls;
static char *kwlist[] = {"lockspace", "host_id",
"path", "offset",
@@ -866,14 +867,14 @@ py_rem_lockspace(PyObject *self __unused, PyObject *args, PyObject
*keywds)
memset(&ls, 0, sizeof(struct sanlk_lockspace));
/* parse python tuple */
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "sks|kii", kwlist,
- &lockspace, &ls.host_id, &path, &ls.host_id_disk.offset,
&async,
- &unused)) {
- return NULL;
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "O&ks|kii", kwlist,
+ convert_to_pybytes, &lockspace, &ls.host_id, &path,
&ls.host_id_disk.offset,
+ &async, &unused)) {
+ goto finally;
}
/* prepare sanlock names */
- strncpy(ls.name, lockspace, SANLK_NAME_LEN);
+ strncpy(ls.name, PyBytes_AsString(lockspace), SANLK_NAME_LEN);
strncpy(ls.host_id_disk.path, path, SANLK_PATH_LEN - 1);
/* prepare sanlock_rem_lockspace flags */
@@ -892,9 +893,13 @@ py_rem_lockspace(PyObject *self __unused, PyObject *args, PyObject
*keywds)
if (rv != 0) {
__set_exception(rv, "Sanlock lockspace remove failure");
- return NULL;
+ goto finally;
}
+finally:
+ Py_XDECREF(lockspace);
+ if (rv != 0)
+ return NULL;
Py_RETURN_NONE;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.