diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-05-09 13:14:22 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-05-09 13:14:22 -0400 |
commit | 96d3219176398f377dc4a1c84e14a54e7d2516df (patch) | |
tree | 5ea0e332e40d233d798f17e48f18aceb4ebc4de6 | |
parent | 39ac1db60e8b920e1e6b07e08f7f3343960ece79 (diff) | |
parent | 00e2310f12dfb91aca2949463b57bd6937f19166 (diff) | |
download | tor-96d3219176398f377dc4a1c84e14a54e7d2516df.tar.gz tor-96d3219176398f377dc4a1c84e14a54e7d2516df.zip |
Merge branch 'bug8844_v2' into maint-0.2.3
-rw-r--r-- | changes/bug8844 | 6 | ||||
-rw-r--r-- | src/or/buffers.c | 3 | ||||
-rw-r--r-- | src/test/test.c | 12 |
3 files changed, 20 insertions, 1 deletions
diff --git a/changes/bug8844 b/changes/bug8844 new file mode 100644 index 0000000000..320e5f2845 --- /dev/null +++ b/changes/bug8844 @@ -0,0 +1,6 @@ + o Major bugfixes: + - Prevent the get_freelists() function from running off the end of + the list of freelists if it somehow gets an unrecognized + allocation. Fixes bug 8844; bugfix on 0.2.0.16-alpha. Reported by + eugenis. + diff --git a/src/or/buffers.c b/src/or/buffers.c index ad5ab83e4f..9be0476f64 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -147,7 +147,8 @@ static INLINE chunk_freelist_t * get_freelist(size_t alloc) { int i; - for (i=0; freelists[i].alloc_size <= alloc; ++i) { + for (i=0; (freelists[i].alloc_size <= alloc && + freelists[i].alloc_size); ++i ) { if (freelists[i].alloc_size == alloc) { return &freelists[i]; } diff --git a/src/test/test.c b/src/test/test.c index ddfd6337bd..ae423948ec 100644 --- a/src/test/test.c +++ b/src/test/test.c @@ -802,6 +802,18 @@ test_buffers(void) buf_free(buf); buf = NULL; + /* Try adding a string too long for any freelist. */ + { + char *cp = tor_malloc_zero(65536); + buf = buf_new(); + write_to_buf(cp, 65536, buf); + tor_free(cp); + + tt_int_op(buf_datalen(buf), ==, 65536); + buf_free(buf); + buf = NULL; + } + done: if (buf) buf_free(buf); |