summaryrefslogtreecommitdiff
path: root/src/common/buffers_tls.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-09-29 10:05:35 -0400
committerNick Mathewson <nickm@torproject.org>2017-09-29 10:29:33 -0400
commitb0ddaac07428a06b3167a3cf7be848d45bf3e406 (patch)
treec42df5d06208b47b0a460201b60e224ce6b8f5ff /src/common/buffers_tls.c
parent4e6374c26b909027bd90ad722902205e5eaa13f4 (diff)
downloadtor-b0ddaac07428a06b3167a3cf7be848d45bf3e406.tar.gz
tor-b0ddaac07428a06b3167a3cf7be848d45bf3e406.zip
Make some assertions nonfatal to help prevent bug23690 recurrence.
Diffstat (limited to 'src/common/buffers_tls.c')
-rw-r--r--src/common/buffers_tls.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/common/buffers_tls.c b/src/common/buffers_tls.c
index 8dbd4bcc8e..041f78b818 100644
--- a/src/common/buffers_tls.c
+++ b/src/common/buffers_tls.c
@@ -142,8 +142,12 @@ buf_flush_to_tls(buf_t *buf, tor_tls_t *tls, size_t flushlen,
size_t flushed = 0;
ssize_t sz;
tor_assert(buf_flushlen);
- tor_assert(*buf_flushlen <= buf->datalen);
- tor_assert(flushlen <= *buf_flushlen);
+ if (BUG(*buf_flushlen > buf->datalen)) {
+ *buf_flushlen = buf->datalen;
+ }
+ if (BUG(flushlen > *buf_flushlen)) {
+ flushlen = *buf_flushlen;
+ }
sz = (ssize_t) flushlen;
/* we want to let tls write even if flushlen is zero, because it might