From 5544ed8bc4a56b2f566d0a96e154a590239af8d2 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 9 Feb 2013 18:46:40 +0000 Subject: [PATCH] Added check for graph timespan overflowing if time_t is 32 bits. --- src/rrd_create.c | 7 +++++++ 1 file changed, 7 insertions(+) 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; } -- 2.47.2