From: Nick Date: Sat, 9 Feb 2013 18:46:40 +0000 (+0000) Subject: Added check for graph timespan overflowing if time_t is 32 bits. X-Git-Tag: v1.5.0-rc1~196^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F369%2Fhead;p=thirdparty%2Frrdtool-1.x.git Added check for graph timespan overflowing if time_t is 32 bits. --- diff --git a/src/rrd_create.c b/src/rrd_create.c index a36b31d1..fd7b9e1b 100644 --- a/src/rrd_create.c +++ b/src/rrd_create.c @@ -12,6 +12,7 @@ #include "rrd_rpncalc.h" #include "rrd_hw.h" #include "rrd_client.h" +#include "../rrd_config.h" #include "rrd_is_thread_safe.h" @@ -478,6 +479,12 @@ int rrd_create_r2( row_cnt = atoi(token); if (row_cnt <= 0) rrd_set_error("Invalid row count: %i", row_cnt); +#if SIZEOF_TIME_T == 4 + if ((long long) pdp_step * rrd.rra_def[rrd.stat_head->rra_cnt].pdp_cnt * row_cnt > 4294967296){ + /* database timespan > 2**32, would overflow time_t */ + rrd_set_error("The time spanned by the database is too large: must be <= 4294967296 seconds"); + } +#endif rrd.rra_def[rrd.stat_head->rra_cnt].row_cnt = row_cnt; break; }