aboutsummaryrefslogtreecommitdiff
path: root/src/or/buffers.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-01-03 13:07:43 -0500
committerNick Mathewson <nickm@torproject.org>2011-01-03 13:07:43 -0500
commit8932753169a25c6410565490267f2158eb555160 (patch)
treece611d1553784fccc45adaa175feb2765a50762f /src/or/buffers.c
parent394a6bf4cdf91efb49b047e08012e834e04aa1c4 (diff)
parent305ba230fef87c072e31ed4fc5acfa2d371e948c (diff)
downloadtor-8932753169a25c6410565490267f2158eb555160.tar.gz
tor-8932753169a25c6410565490267f2158eb555160.zip
Merge remote branch 'rransom/bug2327-v2'
Diffstat (limited to 'src/or/buffers.c')
-rw-r--r--src/or/buffers.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index ef17214b6a..9f393b9874 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -1954,13 +1954,17 @@ fetch_from_evbuffer_socks_client(struct evbuffer *buf, int state,
size_t datalen;
int r;
- data = evbuffer_pullup(buf, 128); /* Make sure we have at least 128
- * contiguous bytes if possible. */
- datalen = evbuffer_get_contiguous_space(buf);
+ /* 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;
+ data = evbuffer_pullup(buf, datalen);
+
r = parse_socks_client(data, datalen, state, reason, &drain);
if (drain > 0)
evbuffer_drain(buf, drain);
- else
+ else if (drain < 0)
evbuffer_drain(buf, evbuffer_get_length(buf));
return r;