[rrd-developers] Uninitialized pointer prevents dump/tune of RRD with CDEF

Chris Adams cmadams at hiwaay.net
Thu Oct 26 23:07:08 MEST 2006


I couldn't dump an RRD (created by Cricket if that might matter) with a
CDEF.  I finally tracked it down to an uninitialized pointer in
rrd_dump.c.  There appears to be an identical bug in rrd_tune.c

Here's a patch:

diff -urN rrdtool-1.2.15-dist/src/rrd_dump.c rrdtool-1.2.15/src/rrd_dump.c
--- rrdtool-1.2.15-dist/src/rrd_dump.c	2006-07-14 07:11:26.000000000 -0500
+++ rrdtool-1.2.15/src/rrd_dump.c	2006-10-26 15:12:52.000000000 -0500
@@ -131,7 +131,7 @@
 	  fprintf(out_file, "\t\t<max> %0.10e </max>\n",rrd.ds_def[i].par[DS_max_val].u_val);
 	}
     } else { /* DST_CDEF */
-	  char *str;
+	  char *str = 0;
 	  rpn_compact2str((rpn_cdefds_t *) &(rrd.ds_def[i].par[DS_cdef]),rrd.ds_def,&str);
 	  fprintf(out_file, "\t\t<cdef> %s </cdef>\n", str);
 	  free(str);
diff -urN rrdtool-1.2.15-dist/src/rrd_tune.c rrdtool-1.2.15/src/rrd_tune.c
--- rrdtool-1.2.15-dist/src/rrd_tune.c	2006-07-14 07:11:26.000000000 -0500
+++ rrdtool-1.2.15/src/rrd_tune.c	2006-10-26 15:13:14.000000000 -0500
@@ -290,7 +290,7 @@
 		   rrd.ds_def[i].par[DS_min_val].u_val,
 		   rrd.ds_def[i].par[DS_max_val].u_val);
 		} else {
-		char *buffer;
+		char *buffer = 0;
 		rpn_compact2str((rpn_cdefds_t *) &(rrd.ds_def[i].par[DS_cdef]),rrd.ds_def,&buffer);
 		printf("DS[%s] typ: %s\tcdef: %s\n", rrd.ds_def[i].ds_nam,rrd.ds_def[i].dst,buffer);
 	    free(buffer);


-- 
Chris Adams <cmadams at hiwaay.net>
Systems and Network Administrator - HiWAAY Internet Services
I don't speak for anybody but myself - that's enough trouble.

--
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