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=e16bceb40c083f21d9242d261542f98ac70fa288;p=rrdtool-all.git check row count in RRAs to be > 0 ... by Sebastian Harl git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1424 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/doc/rrdcreate.pod b/program/doc/rrdcreate.pod index 86817bd4..03012e03 100644 --- a/program/doc/rrdcreate.pod +++ b/program/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/program/src/rrd_create.c b/program/src/rrd_create.c index 028123ef..6d7cb18e 100644 --- a/program/src/rrd_create.c +++ b/program/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;