Check shift used in freq_est and stats max_count calculation.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
master
Miroslav Lichvar 2013-02-12 13:23:06 +01:00 committed by Richard Cochran
parent 7d8f31da45
commit c547145834
2 changed files with 12 additions and 0 deletions

View File

@ -999,11 +999,19 @@ void clock_sync_interval(struct clock *c, int n)
shift = c->freq_est_interval - n; shift = c->freq_est_interval - n;
if (shift < 0) if (shift < 0)
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); c->fest.max_count = (1 << shift);
shift = c->stats_interval - n; shift = c->stats_interval - n;
if (shift < 0) if (shift < 0)
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); c->stats.max_count = (1 << shift);
} }

4
port.c
View File

@ -551,6 +551,10 @@ static void port_nrate_initialize(struct port *p)
if (shift < 0) if (shift < 0)
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. */ /* We start in the 'incapable' state. */
p->pdr_missing = ALLOWED_LOST_RESPONSES + 1; p->pdr_missing = ALLOWED_LOST_RESPONSES + 1;