Skip to content

Commit

Permalink
ratelimit: fix buffer overflow when using SBT algorithm
Browse files Browse the repository at this point in the history
Make sure the window doesn't overflow
Fixes #1176

(cherry picked from commit d885463)
  • Loading branch information
razvancrainea committed Aug 31, 2017
1 parent e3f4d0f commit 3292cd9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/ratelimit/ratelimit.c
Expand Up @@ -555,8 +555,8 @@ static inline int hist_check(rl_pipe_t *pipe)
pipe->rwin.start_index = first_good_index;

/* count current call; it will be the last element in the window */
pipe->rwin.window[(pipe->rwin.start_index)
+ (pipe->rwin.window_size-1) % pipe->rwin.window_size]++;
pipe->rwin.window[((pipe->rwin.start_index)
+ (pipe->rwin.window_size-1)) % pipe->rwin.window_size]++;

} else { /* now_total - start_total < rl_win_ms */
/* no need to modify the window, the value is inside it;
Expand Down

0 comments on commit 3292cd9

Please sign in to comment.