diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-12-15 11:35:23 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-12-15 11:35:23 -0500 |
commit | 03c7d9e992f250a484d4770af12271e742a3bd81 (patch) | |
tree | 20fdfe29866eafcd106a3980b801101f148c6348 | |
parent | 5eff44ca8e517efdb72492e27812f0a8baf44b00 (diff) | |
parent | 9d0777839be6642954a4c064c819d406d8bb7cb4 (diff) | |
download | tor-03c7d9e992f250a484d4770af12271e742a3bd81.tar.gz tor-03c7d9e992f250a484d4770af12271e742a3bd81.zip |
Merge branch 'maint-0.2.1' into release-0.2.1
-rw-r--r-- | changes/buffer_bug | 7 | ||||
-rw-r--r-- | src/or/buffers.c | 5 |
2 files changed, 10 insertions, 2 deletions
diff --git a/changes/buffer_bug b/changes/buffer_bug new file mode 100644 index 0000000000..634f609533 --- /dev/null +++ b/changes/buffer_bug @@ -0,0 +1,7 @@ + + o Major bugfixes: + - Fix a heap overflow bug that could occur when trying to pull + data into the first chunk of a buffer, when that chunk had + already had some data drained from it. Fixes CVE-2011-2778; + bugfix on 0.2.0.16-alpha. Reported by "Vektor". + diff --git a/src/or/buffers.c b/src/or/buffers.c index 710374638b..5701604909 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; |