Skip to content

Commit

Permalink
assert in case resize output buffer will attempt to shrink too much (#…
Browse files Browse the repository at this point in the history
…11839)

Currently there is no BUG. However during some internal code changes
I found that it can happen (for example in case new code will not update
the buf_peak) which can currently lead to memory overrun which is much
harder to detect and root cause.

Why did I please the assert here? The reason is to be able to have the
buf_peak value without the risk of it being overriden by the peak_reset
  • Loading branch information
ranshid committed Feb 26, 2023
1 parent c8226ae commit 4972760
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,8 @@ int clientsCronResizeOutputBuffer(client *c, mstime_t now_ms) {
server.stat_reply_buffer_expands++;
}

serverAssertWithInfo(c, NULL, (!new_buffer_size) || (new_buffer_size >= (size_t)c->bufpos));

/* reset the peak value each server.reply_buffer_peak_reset_time seconds. in case the client will be idle
* it will start to shrink.
*/
Expand Down

0 comments on commit 4972760

Please sign in to comment.