From: oetiker Date: Mon, 16 Jan 2012 10:59:14 +0000 (+0000) Subject: rrdtool is assuming that rrd_xport will always return -1 on failure; X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5d9debc39e89fada87f4962087a0be950f911623;p=rrdtool-all.git rrdtool is assuming that rrd_xport will always return -1 on failure; however, rrd_xport returns errno (which is, generally, not -1) if rrd_client fails. I figured it was easier to change rrdtool than to change everything in rrd_client. For good measure, I also changed the checks on the calls to rrd_fetch and rrd_graph. I'm not sure if they're susceptible to the same problem, but, well, better to check for the one thing you do what you want than to enumerate all the possible things you don't want. This segfault is caused by an uninitialized variable use (in particular, legend_v and col_cnt end up being used and passed to printf uninitialized). Nothing offhand jumped out at me as easily-exploitable to do code injection, but I only spent five or so minutes looking at it, so there very well may be a security problem hiding behind this. -- James Brown git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.4@2251 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/src/rrd_tool.c b/program/src/rrd_tool.c index 7d258bf6..2c67353a 100644 --- a/program/src/rrd_tool.c +++ b/program/src/rrd_tool.c @@ -685,7 +685,7 @@ int HandleInputLine( if (rrd_fetch (argc - 1, &argv[1], &start, &end, &step, &ds_cnt, &ds_namv, - &data) != -1) { + &data) == 0) { datai = data; printf(" "); for (i = 0; i < ds_cnt; i++) @@ -725,7 +725,7 @@ int HandleInputLine( if (rrd_xport (argc - 1, &argv[1], &xxsize, &start, &end, &step, &col_cnt, - &legend_v, &data) != -1) { + &legend_v, &data) == 0) { char *old_locale = setlocale(LC_NUMERIC,NULL); setlocale(LC_NUMERIC, "C"); row_cnt = (end - start) / step; @@ -869,7 +869,7 @@ int HandleInputLine( } if (rrd_graph (argc - 1, &argv[1], &calcpr, &xsize, &ysize, NULL, &ymin, - &ymax) != -1) { + &ymax) == 0) { if (!tostdout && !imginfo) printf("%dx%d\n", xsize, ysize); if (calcpr) {