diff options
author | Robert Ransom <rransom.8774@gmail.com> | 2010-12-29 05:11:29 -0800 |
---|---|---|
committer | Robert Ransom <rransom.8774@gmail.com> | 2010-12-29 05:52:09 -0800 |
commit | 524fdeeb1ec6c1d84c75a793b6feba1f7d9d88cf (patch) | |
tree | 21323f372ce1489a21f1d44d2e238eabe0db0994 /src/or/buffers.c | |
parent | da9190013510412cec00e38c064c5c718d032f9e (diff) | |
download | tor-524fdeeb1ec6c1d84c75a793b6feba1f7d9d88cf.tar.gz tor-524fdeeb1ec6c1d84c75a793b6feba1f7d9d88cf.zip |
Use evbuffer_pullup properly in fetch_from_evbuffer_socks_client.
evbuffer_pullup does nothing and returns NULL if the caller asks it to
linearize more data than the buffer contains.
Introduced in 9796b9bfa6a757780d6185547e4baf739c53cdac.
Reported by piebeer; fixed with help from doors.
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 1018a24499..81d54d648f 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -1954,9 +1954,13 @@ 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); |