aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2020-07-30 14:24:25 -0400
committerNick Mathewson <nickm@torproject.org>2020-07-30 14:24:25 -0400
commitc4742b89b23d58958ee0d5ca324dac5948c94bf6 (patch)
treef403e603d110b8a2f986051d45f240c17eb43e8a /src/lib
parent0a588821cb5540e901a3d5b07ac73a20905a2c64 (diff)
downloadtor-c4742b89b23d58958ee0d5ca324dac5948c94bf6.tar.gz
tor-c4742b89b23d58958ee0d5ca324dac5948c94bf6.zip
Fix a bug in buf_move_all() when the input buffer is empty.
We found this in #40076, after we started using buf_move_all() in more places. Fixes bug #40076; bugfix on 0.3.3.1-alpha. As far as I know, the crash only affects master, but I think this warrants a backport, "just in case".
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/container/buffers.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/lib/container/buffers.c b/src/lib/container/buffers.c
index 67887f2f30..fe4cf7c385 100644
--- a/src/lib/container/buffers.c
+++ b/src/lib/container/buffers.c
@@ -689,6 +689,8 @@ buf_move_all(buf_t *buf_out, buf_t *buf_in)
tor_assert(buf_out);
if (!buf_in)
return;
+ if (buf_datalen(buf_in) == 0)
+ return;
if (BUG(buf_out->datalen >= INT_MAX || buf_in->datalen >= INT_MAX))
return;
if (BUG(buf_out->datalen >= INT_MAX - buf_in->datalen))