Skip to content

Commit

Permalink
Check shift used in freq_est and stats max_count calculation.
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Lichvar <[email protected]>
  • Loading branch information
mlichvar authored and richardcochran committed Feb 12, 2013
1 parent 7d8f31d commit c547145
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 4 additions & 0 deletions port.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c547145

Please sign in to comment.