[rrd-developers] rrdtool: update crash

Bernhard Fischer rep.dot.nop at gmail.com
Tue Jun 10 11:53:38 CEST 2008


On Tue, Jun 10, 2008 at 11:24:29AM +0200, Sebastian Harl wrote:
>diff --git a/program/src/rrd_create.c b/program/src/rrd_create.c
>index bb8d45d..cc93109 100644
>--- a/program/src/rrd_create.c
>+++ b/program/src/rrd_create.c
>@@ -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);

It would look more obvious if you moved the check of row_cnt right after
the atoi().

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

ditto.



More information about the rrd-developers mailing list