diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-04-24 08:15:53 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2020-04-24 08:15:53 -0400 |
commit | 4dd4dbf046693be581dd05cdae1c62e68472d18e (patch) | |
tree | 1c92656beb6321ae5d6fe91239c8553fea815de4 /src/core | |
parent | 7f9eaec538b7d01e0d1b130dc4cf2ec634252d46 (diff) | |
parent | 64a934ff05575d63401fcdfdc6363df32191106c (diff) | |
download | tor-4dd4dbf046693be581dd05cdae1c62e68472d18e.tar.gz tor-4dd4dbf046693be581dd05cdae1c62e68472d18e.zip |
Merge remote-tracking branch 'onionk/inbufoverflow1-043' into ticket33131_044
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/mainloop/connection.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/core/mainloop/connection.c b/src/core/mainloop/connection.c index 9602978458..db59e6b28d 100644 --- a/src/core/mainloop/connection.c +++ b/src/core/mainloop/connection.c @@ -3814,6 +3814,12 @@ connection_buf_read_from_socket(connection_t *conn, ssize_t *max_to_read, at_most = connection_bucket_read_limit(conn, approx_time()); } + /* Do not allow inbuf to grow past BUF_MAX_LEN. */ + const ssize_t maximum = BUF_MAX_LEN - buf_datalen(conn->inbuf); + if (at_most > maximum) { + at_most = maximum; + } + slack_in_buf = buf_slack(conn->inbuf); again: if ((size_t)at_most > slack_in_buf && slack_in_buf >= 1024) { |