diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-12-14 16:38:43 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-12-15 11:28:24 -0500 |
commit | 9d0777839be6642954a4c064c819d406d8bb7cb4 (patch) | |
tree | 6c19e41480bb925c9099180dd1e6c36dc12b0aad /src/or | |
parent | ff2c9acbb39d7ae917501b1e719cf5be994fe4e2 (diff) | |
download | tor-9d0777839be6642954a4c064c819d406d8bb7cb4.tar tor-9d0777839be6642954a4c064c819d406d8bb7cb4.tar.gz |
Add a fix for the buf_pullup bug that Vektor reported
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/buffers.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c index 710374638..570160490 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -375,9 +375,10 @@ buf_pullup(buf_t *buf, size_t bytes, int nulterminate) if (buf->head->memlen >= capacity) { /* We don't need to grow the first chunk, but we might need to repack it.*/ - if (CHUNK_REMAINING_CAPACITY(buf->head) < capacity-buf->datalen) + size_t needed = capacity - buf->head->datalen; + if (CHUNK_REMAINING_CAPACITY(buf->head) < needed) chunk_repack(buf->head); - tor_assert(CHUNK_REMAINING_CAPACITY(buf->head) >= capacity-buf->datalen); + tor_assert(CHUNK_REMAINING_CAPACITY(buf->head) >= needed); } else { chunk_t *newhead; size_t newsize; |