diff --git a/clock.c b/clock.c index 974b37c..e4e4f30 100644 --- a/clock.c +++ b/clock.c @@ -999,11 +999,19 @@ void clock_sync_interval(struct clock *c, int n) shift = c->freq_est_interval - n; if (shift < 0) shift = 0; + else if (shift >= sizeof(int) * 8) { + shift = sizeof(int) * 8 - 1; + pr_warning("freq_est_interval is too long"); + } c->fest.max_count = (1 << shift); shift = c->stats_interval - n; if (shift < 0) shift = 0; + else if (shift >= sizeof(int) * 8) { + shift = sizeof(int) * 8 - 1; + pr_warning("summary_interval is too long"); + } c->stats.max_count = (1 << shift); } diff --git a/port.c b/port.c index 1438808..9899687 100644 --- a/port.c +++ b/port.c @@ -551,6 +551,10 @@ static void port_nrate_initialize(struct port *p) if (shift < 0) shift = 0; + else if (shift >= sizeof(int) * 8) { + shift = sizeof(int) * 8 - 1; + pr_warning("freq_est_interval is too long"); + } /* We start in the 'incapable' state. */ p->pdr_missing = ALLOWED_LOST_RESPONSES + 1;