From 65c47a01078ff0a6e12e51b97d18f94387dc7da5 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 15 Dec 2015 14:45:58 +0000 Subject: [PATCH] python-rrdtool: Update to version 0.1.2 Signed-off-by: Michael Tremer --- .../patches/python-rrdtool-fix-SEGV.patch | 47 +++++++++++++++++++ python-rrdtool/python-rrdtool.nm | 5 +- 2 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 python-rrdtool/patches/python-rrdtool-fix-SEGV.patch diff --git a/python-rrdtool/patches/python-rrdtool-fix-SEGV.patch b/python-rrdtool/patches/python-rrdtool-fix-SEGV.patch new file mode 100644 index 000000000..c45316d4c --- /dev/null +++ b/python-rrdtool/patches/python-rrdtool-fix-SEGV.patch @@ -0,0 +1,47 @@ +From a45ed2ad6f92730a479522c46febb1b56b442aba Mon Sep 17 00:00:00 2001 +From: Michael Tremer +Date: Mon, 23 Nov 2015 02:15:33 +0000 +Subject: [PATCH] Fix crash in lastupdate() method + +When a RRD database contains floating point values, the +PyRRD_Int_FromString function returns NULL, which will then be tried +to be put into a dictionary. +This operation fails as PyDict_SetItemString does not handle NULL +and the program crashes with SEGV. + +This patch parses the value as a floating point number +and will add that instead. If the value could not be parsed, +None will be added instead. + +Signed-off-by: Michael Tremer +--- + rrdtoolmodule.c | 16 +++++++++++++--- + 1 file changed, 13 insertions(+), 3 deletions(-) + +diff --git a/rrdtoolmodule.c b/rrdtoolmodule.c +index dead4ff..4713850 100644 +--- a/rrdtoolmodule.c ++++ b/rrdtoolmodule.c +@@ -880,9 +880,19 @@ _rrdtool_lastupdate(PyObject *self, PyObject *args) + PyDict_SetItemString(ret, "ds", ds_dict); + + for (i = 0; i < ds_cnt; i++) { +- PyDict_SetItemString(ds_dict, +- ds_names[i], +- PyRRD_Int_FromString(last_ds[i], NULL, 10)); ++ PyObject* val = Py_None; ++ ++ double num; ++ if (sscanf(last_ds[i], "%lf", &num) == 1) { ++ val = PyFloat_FromDouble(num); ++ } ++ ++ if (!val) ++ return NULL; ++ ++ PyDict_SetItemString(ds_dict, ds_names[i], val); ++ Py_DECREF(val); ++ + free(last_ds[i]); + free(ds_names[i]); + } diff --git a/python-rrdtool/python-rrdtool.nm b/python-rrdtool/python-rrdtool.nm index 6d3d49a7f..7fa8b8b7a 100644 --- a/python-rrdtool/python-rrdtool.nm +++ b/python-rrdtool/python-rrdtool.nm @@ -4,9 +4,8 @@ ############################################################################### name = python-rrdtool -version = 0.1.1 -release = 2 -thisapp = rrdtool-%{version} +version = 0.1.2 +release = 1 groups = System/Libraries url = https://github.com/commx/python-rrdtool -- 2.47.3