[rrd-developers] Three bugs in 1.0.50 rrd_graph.c

Blair Zajac blair at orcaware.com
Mon May 2 08:05:14 MEST 2005

Hi Tobi,

I just got 1.0.50 and compiled it with -Wall on gcc 3.4.4 and got these 

  /usr/bin/gcc-3.4 -DHAVE_CONFIG_H -I. -I. -I.. -I../cgilib-0.4 
-I../gd1.3 -Os -march=i386 -mtune=i686 -Wall -MT rrd_graph.lo -MD -MP 
-MF .deps/rrd_graph.Tpo -c
rrd_graph.c -o rrd_graph.o
rrd_graph.c: In function `copyImage':
rrd_graph.c:2463: warning: passing arg 1 of `close' makes integer from 
pointer without a cast
rrd_graph.c: In function `graph_paint':
rrd_graph.c:2626: warning: the address of `rrd_test_error', will always 
evaluate as `true'
rrd_graph.c:2773: warning: the address of `rrd_test_error', will always 
evaluate as `true'

The first could cause a resource leak in file descriptors because the 
FILE* is being passed to close() and not fclose() and is not properly 
closed.  The last two are just missing ()'s in the function call.

Below is a patch.


Blair Zajac, Ph.D.
<blair at orcaware.com>
Subversion and Orca training and consulting

Index: rrd_graph.c
--- rrd_graph.c (revision 439)
+++ rrd_graph.c (working copy)
@@ -2460,7 +2460,7 @@
-     close(fi);
+     fclose(fi);
     } else {
       rrd_set_error("Error Opeing %s: %s",image,  strerror(errno));
@@ -2623,7 +2623,7 @@

    if (im->bkg_image){  /* background image added first */
-    if (rrd_test_error) return(-1);
+    if (rrd_test_error()) return(-1);
@@ -2770,7 +2770,7 @@

    if (im->ovl_image) { /* overlay image added last */
-    if (rrd_test_error) return(-1);
+    if (rrd_test_error()) return(-1);
      if (strcmp(im->graphfile,"-")==0) {
  #ifdef WIN32

Unsubscribe mailto:rrd-developers-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-developers-request at list.ee.ethz.ch?subject=help
Archive     http://lists.ee.ethz.ch/rrd-developers
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi

More information about the rrd-developers mailing list