From: Andre Noll Date: Sun, 28 Oct 2012 19:11:16 +0000 (+0100) Subject: Reject insane number of intervals. X-Git-Tag: v0.1.5~5 X-Git-Url: http://git.tuebingen.mpg.de/?p=dss.git;a=commitdiff_plain;h=024b342374b97ce23ac35f4ff7da146f1088d94b Reject insane number of intervals. Nobody needs more than 2^30 snapshots. More importantly, values larger than 32 for --num_intervals cause an integer overflow in desired_number_of_snapshots() because the number of snapshots in interval zero does not fit in an unsigned int in this case. This patch adds a test to check_config() that rejects values larger than 30 for the --num_intervals option. Many thanks to Klaus Kopec for pointing out this bug. --- diff --git a/dss.c b/dss.c index 7620cfe..258cd3f 100644 --- a/dss.c +++ b/dss.c @@ -932,8 +932,9 @@ static int check_config(void) return -E_INVALID_NUMBER; } DSS_DEBUG_LOG(("unit interval: %i day(s)\n", conf.unit_interval_arg)); - if (conf.num_intervals_arg <= 0) { - DSS_ERROR_LOG(("bad number of intervals %i\n", conf.num_intervals_arg)); + if (conf.num_intervals_arg <= 0 || conf.num_intervals_arg > 30) { + DSS_ERROR_LOG(("bad number of intervals: %i\n", + conf.num_intervals_arg)); return -E_INVALID_NUMBER; } DSS_DEBUG_LOG(("number of intervals: %i\n", conf.num_intervals_arg));