rrd_open() returns either a pointer or NULL, but PyRRD_info() tests the return value against -1. if there's a problem opening the file, the error handling code is skipped anyway, and it attempts to fclose() an invalid filehandle. the fclose() is unnecessary anyway, because any opened files are already closed by rrd_open().

there's also a mismatch between the function definitions for rrd_open in src/rrd.h and bindings/python/rrd_extra.h. so rrd_open() gets a bad pointer to the rrd_t struct. when this parameter gets initialised, it results in the saved %ebp and %eip being overwritten with NULLs. this is obviously a slight problem when PyRRD_info() tries to return.

the attached patch (against svn r1331) should fix both these issues.

cheers,

--matt


--
Matthew Boyle
Junior Systems Administrator
DecisionSoft Limited                        http://www.decisionsoft.com
Index: bindings/python/rrdtoolmodule.c
===================================================================
--- bindings/python/rrdtoolmodule.c	(revision 1331)
+++ bindings/python/rrdtoolmodule.c	(working copy)
@@ -411,19 +411,17 @@
 {
     PyObject *r, *t, *ds;
     rrd_t     rrd;
-    FILE     *in_file;
     char     *filename;
     unsigned long i, j;
 
     if (!PyArg_ParseTuple(args, "s:info", &filename))
         return NULL;
 
-    if (rrd_open(filename, &in_file, &rrd, RRD_READONLY) == -1) {
+    if (! rrd_open(filename, &rrd, RRD_READONLY)) {
         PyErr_SetString(ErrorObject, rrd_get_error());
         rrd_clear_error();
         return NULL;
     }
-    fclose(in_file);
 
 #define DICTSET_STR(dict, name, value) \
     t = PyString_FromString(value); \
Index: bindings/python/rrd_extra.h
===================================================================
--- bindings/python/rrd_extra.h	(revision 1331)
+++ bindings/python/rrd_extra.h	(working copy)
@@ -53,7 +53,6 @@
 
     int       rrd_open(
     char *file_name,
-    FILE ** in_file,
     rrd_t *rrd,
     int rdwr);
     int       readfile(
_______________________________________________
rrd-developers mailing list
[email protected]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers

Reply via email to