mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 14:23:30 +01:00
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 9796b9bfa6
.
Reported by piebeer; fixed with help from doors.
This commit is contained in:
parent
da91900135
commit
524fdeeb1e
@ -1954,9 +1954,13 @@ fetch_from_evbuffer_socks_client(struct evbuffer *buf, int state,
|
|||||||
size_t datalen;
|
size_t datalen;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
data = evbuffer_pullup(buf, 128); /* Make sure we have at least 128
|
/* Linearize the SOCKS response in the buffer, up to 128 bytes.
|
||||||
* contiguous bytes if possible. */
|
* (parse_socks_client shouldn't need to see anything beyond that.) */
|
||||||
datalen = evbuffer_get_contiguous_space(buf);
|
datalen = evbuffer_get_length(buf);
|
||||||
|
if (datalen > 128)
|
||||||
|
datalen = 128;
|
||||||
|
data = evbuffer_pullup(buf, datalen);
|
||||||
|
|
||||||
r = parse_socks_client(data, datalen, state, reason, &drain);
|
r = parse_socks_client(data, datalen, state, reason, &drain);
|
||||||
if (drain > 0)
|
if (drain > 0)
|
||||||
evbuffer_drain(buf, drain);
|
evbuffer_drain(buf, drain);
|
||||||
|
Loading…
Reference in New Issue
Block a user