diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-01-10 17:31:11 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-01-10 17:31:11 -0500 |
commit | c9f8a5eebcfbda9d88148e031b43c064f31f20a3 (patch) | |
tree | 8f9518c8083fc7744edd7e213854d299688a8d16 /src/or/buffers.c | |
parent | f12b253639fa9df71b53c0eb44109a02e7ba41b5 (diff) | |
parent | aa45e8259368c9733e459dc4f91f62492b9926da (diff) | |
download | tor-c9f8a5eebcfbda9d88148e031b43c064f31f20a3.tar.gz tor-c9f8a5eebcfbda9d88148e031b43c064f31f20a3.zip |
Merge remote branch 'origin/maint-0.2.2'
Conflicts:
src/or/buffers.c
Diffstat (limited to 'src/or/buffers.c')
-rw-r--r-- | src/or/buffers.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c index 9f393b9874..bf84fad804 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -1475,6 +1475,10 @@ log_unsafe_socks_warning(int socks_protocol, const char *address, socks_protocol, address, (int)port); } +/** Do not attempt to parse socks messages longer than this. This value is + * actually significantly higher than the longest possible socks message. */ +#define MAX_SOCKS_MESSAGE_LEN 512 + /** There is a (possibly incomplete) socks handshake on <b>buf</b>, of one * of the forms * - socks4: "socksheader username\\0" @@ -1930,7 +1934,7 @@ fetch_from_buf_socks_client(buf_t *buf, int state, char **reason) if (buf->datalen < 2) return 0; - buf_pullup(buf, 128, 0); + buf_pullup(buf, MAX_SOCKS_MESSAGE_LEN, 0); tor_assert(buf->head && buf->head->datalen >= 2); r = parse_socks_client((uint8_t*)buf->head->data, buf->head->datalen, @@ -1957,8 +1961,8 @@ fetch_from_evbuffer_socks_client(struct evbuffer *buf, int state, /* Linearize the SOCKS response in the buffer, up to 128 bytes. * (parse_socks_client shouldn't need to see anything beyond that.) */ datalen = evbuffer_get_length(buf); - if (datalen > 128) - datalen = 128; + if (datalen > MAX_SOCKS_MESSAGE_LEN) + datalen = MAX_SOCKS_MESSAGE_LEN; data = evbuffer_pullup(buf, datalen); r = parse_socks_client(data, datalen, state, reason, &drain); |