This is an automated email from the git hooks/post-receive script.
nsoffer pushed a commit to branch master
in repository sanlock.
commit c58fb9fc3eeffcf1f94a3df4df3061219cbc4b3a
Author: Amit Bawer <abawer(a)redhat.com>
AuthorDate: Sun May 5 16:29:31 2019 +0300
sanlock: Resource API should only support disks as a tuple
As stated in sanlock module help:
The disks must be in the format: [(path, offset), ... ]
Signed-off-by: Amit Bawer <abawer(a)redhat.com>
---
python/sanlock.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/python/sanlock.c b/python/sanlock.c
index e710f89..446a4b5 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -33,6 +33,7 @@
/* Functions prototypes */
static void __set_exception(int en, char *msg) __sets_exception;
static int __parse_resource(PyObject *obj, struct sanlk_resource **res_ret)
__neg_sets_exception;
+static void set_value_error(const char* format, PyObject* obj);
/* Sanlock module */
PyDoc_STRVAR(pydoc_sanlock, "\
@@ -109,8 +110,10 @@ __parse_resource(PyObject *obj, struct sanlk_resource **res_ret)
__set_exception(EINVAL, "Invalid resource offset");
goto exit_fail;
}
- } else if (PyString_Check(tuple)) {
- p = PyString_AsString(tuple);
+ } else {
+ /* handle invalid non-tuple resource input */
+ set_value_error("invalid disk value: %s", tuple);
+ goto exit_fail;
}
if (p == NULL) {
@@ -184,6 +187,17 @@ add_align_flag(long align, uint32_t *flags)
return 0;
}
+static void
+set_value_error(const char* format, PyObject* obj)
+{
+ const char* str_rep = "";
+ PyObject* rep = PyObject_Repr(obj);
+ if (rep)
+ str_rep = PyString_AsString(rep);
+ PyErr_Format(PyExc_ValueError, format, str_rep);
+ Py_XDECREF(rep);
+}
+
static PyObject *
__hosts_to_list(struct sanlk_host *hss, int hss_count)
{
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.