From: oetiker Date: Tue, 10 Jun 2008 09:35:03 +0000 (+0000) Subject: check row count in RRAs to be > 0 ... by Sebastian Harl X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0cc0426da39afd7d41a8f3848c85543586642ca2;p=rrdtool.git check row count in RRAs to be > 0 ... by Sebastian Harl git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1424 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/doc/rrdcreate.pod b/doc/rrdcreate.pod index 86817bd..03012e0 100644 --- a/doc/rrdcreate.pod +++ b/doc/rrdcreate.pod @@ -216,6 +216,7 @@ I defines how many of these I are used to build a I which then goes into the archive. I defines how many generations of data values are kept in an B. +Obviously, this has to be greater than zero. =back diff --git a/src/rrd_create.c b/src/rrd_create.c index 028123e..6d7cb18 100644 --- a/src/rrd_create.c +++ b/src/rrd_create.c @@ -232,6 +232,7 @@ int rrd_create_r( char *argvcopy; char *tokptr; size_t old_size = sizeof(rra_def_t) * (rrd.stat_head->rra_cnt); + int row_cnt; if ((rrd.rra_def = rrd_realloc(rrd.rra_def, old_size + sizeof(rra_def_t))) == @@ -312,8 +313,10 @@ int rrd_create_r( case CF_SEASONAL: case CF_DEVPREDICT: case CF_FAILURES: - rrd.rra_def[rrd.stat_head->rra_cnt].row_cnt = - atoi(token); + row_cnt = atoi(token); + rrd.rra_def[rrd.stat_head->rra_cnt].row_cnt = row_cnt; + if (row_cnt <= 0) + rrd_set_error("Invalid row count: %i", row_cnt); break; default: rrd.rra_def[rrd.stat_head->rra_cnt]. @@ -416,8 +419,10 @@ int rrd_create_r( ("Unexpected extra argument for consolidation function DEVPREDICT"); break; default: - rrd.rra_def[rrd.stat_head->rra_cnt].row_cnt = - atoi(token); + row_cnt = atoi(token); + rrd.rra_def[rrd.stat_head->rra_cnt].row_cnt = row_cnt; + if (row_cnt <= 0) + rrd_set_error("Invalid row count: %i", row_cnt); break; } break;