mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 12:23:32 +01:00
buf: add BUF_MAX_LEN
This commit is contained in:
parent
d3ded1cc1c
commit
f46b9320ae
@ -3804,8 +3804,8 @@ 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 INT_MAX - 1. */
|
||||
const ssize_t maximum = INT_MAX - 1 - buf_datalen(conn->inbuf);
|
||||
/* 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;
|
||||
}
|
||||
|
@ -29,6 +29,9 @@ void buf_free_(buf_t *buf);
|
||||
void buf_clear(buf_t *buf);
|
||||
buf_t *buf_copy(const buf_t *buf);
|
||||
|
||||
/** Maximum bytes in a buffer, inclusive. */
|
||||
#define BUF_MAX_LEN (INT_MAX - 1)
|
||||
|
||||
MOCK_DECL(size_t, buf_datalen, (const buf_t *buf));
|
||||
size_t buf_allocation(const buf_t *buf);
|
||||
size_t buf_slack(const buf_t *buf);
|
||||
|
Loading…
Reference in New Issue
Block a user