aboutsummaryrefslogtreecommitdiff
path: root/src/lib/tls/buffers_tls.c
diff options
context:
space:
mode:
authorcypherpunks <cypherpunks@torproject.org>2020-03-12 19:15:43 +0000
committercypherpunks <cypherpunks@torproject.org>2020-03-24 05:54:37 +0000
commitbb3eda8617ad06b647542da0f6d62f7dafe31a87 (patch)
tree95704c16b9b6e43f62d8151d3d826e6500661116 /src/lib/tls/buffers_tls.c
parentf46b9320ae32f00aa97a397b33eaa7abdcb47fe3 (diff)
downloadtor-bb3eda8617ad06b647542da0f6d62f7dafe31a87.tar.gz
tor-bb3eda8617ad06b647542da0f6d62f7dafe31a87.zip
net, tls: use INT_MAX - 1 in checks for buf_t
No functionality change.
Diffstat (limited to 'src/lib/tls/buffers_tls.c')
-rw-r--r--src/lib/tls/buffers_tls.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/tls/buffers_tls.c b/src/lib/tls/buffers_tls.c
index 87055744a7..b1e5cb8eed 100644
--- a/src/lib/tls/buffers_tls.c
+++ b/src/lib/tls/buffers_tls.c
@@ -68,9 +68,9 @@ buf_read_from_tls(buf_t *buf, tor_tls_t *tls, size_t at_most)
check_no_tls_errors();
- IF_BUG_ONCE(buf->datalen >= INT_MAX)
+ IF_BUG_ONCE(buf->datalen > INT_MAX - 1)
return TOR_TLS_ERROR_MISC;
- IF_BUG_ONCE(buf->datalen >= INT_MAX - at_most)
+ IF_BUG_ONCE(buf->datalen > INT_MAX - 1 - at_most)
return TOR_TLS_ERROR_MISC;
while (at_most > total_read) {
@@ -90,7 +90,7 @@ buf_read_from_tls(buf_t *buf, tor_tls_t *tls, size_t at_most)
r = read_to_chunk_tls(buf, chunk, tls, readlen);
if (r < 0)
return r; /* Error */
- tor_assert(total_read+r < INT_MAX);
+ tor_assert(total_read+r <= INT_MAX - 1);
total_read += r;
if ((size_t)r < readlen) /* eof, block, or no more to read. */
break;
@@ -177,6 +177,6 @@ buf_flush_to_tls(buf_t *buf, tor_tls_t *tls, size_t flushlen,
if (r == 0) /* Can't flush any more now. */
break;
} while (sz > 0);
- tor_assert(flushed < INT_MAX);
+ tor_assert(flushed <= INT_MAX - 1);
return (int)flushed;
}