Fix spurious warning in bufferevent socks parsing

The problem was that we weren't initializing want_length to 0 before
calling parse_socks() the first time, so it looked like we were
risking an infinite loop when in fact we were safe.

Fixes 3615; bugfix on 0.2.3.2-alpha.
This commit is contained in:
Nick Mathewson 2011-07-19 20:40:15 -04:00
parent c2d3da6303
commit 553ae5dfb5
2 changed files with 5 additions and 2 deletions

3
changes/bug3615 Normal file
View File

@ -0,0 +1,3 @@
o Minor bugfixes:
- Fix a spurious warning when parsing SOCKS requests with
bufferevents enabled. Fixes bug 3615; bugfix on 0.2.3.2-alpha.

View File

@ -1581,12 +1581,12 @@ fetch_from_evbuffer_socks(struct evbuffer *buf, socks_request_t *req,
*/
struct evbuffer_iovec v;
int i;
want_length = evbuffer_get_contiguous_space(buf);
n_drain = 0;
i = evbuffer_peek(buf, want_length, NULL, &v, 1);
i = evbuffer_peek(buf, -1, NULL, &v, 1);
tor_assert(i == 1);
data = v.iov_base;
datalen = v.iov_len;
want_length = 0;
res = parse_socks(data, datalen, req, log_sockstype,
safe_socks, &n_drain, &want_length);