aboutsummaryrefslogtreecommitdiff
path: root/src/or/buffers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/or/buffers.c')
-rw-r--r--src/or/buffers.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index aff113ff6a..2002f4f981 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -1710,15 +1710,7 @@ parse_socks(const char *data, size_t datalen, socks_request_t *req,
req->port = ntohs(get_uint16(data+5+len));
*drain_out = 5+len+2;
- if (string_is_valid_ipv4_address(req->address) ||
- string_is_valid_ipv6_address(req->address)) {
- log_unsafe_socks_warning(5,req->address,req->port,safe_socks);
-
- if (safe_socks) {
- socks_request_set_socks5_error(req, SOCKS5_NOT_ALLOWED);
- return -1;
- }
- } else if (!string_is_valid_hostname(req->address)) {
+ if (!string_is_valid_hostname(req->address)) {
socks_request_set_socks5_error(req, SOCKS5_GENERAL_ERROR);
log_warn(LD_PROTOCOL,
@@ -1840,7 +1832,7 @@ parse_socks(const char *data, size_t datalen, socks_request_t *req,
log_debug(LD_APP,"socks4: Everything is here. Success.");
strlcpy(req->address, startaddr ? startaddr : tmpbuf,
sizeof(req->address));
- if (!tor_strisprint(req->address) || strchr(req->address,'\"')) {
+ if (!string_is_valid_hostname(req->address)) {
log_warn(LD_PROTOCOL,
"Your application (using socks4 to port %d) gave Tor "
"a malformed hostname: %s. Rejecting the connection.",
@@ -2122,7 +2114,7 @@ fetch_from_buf_line(buf_t *buf, char *data_out, size_t *data_len)
int
write_to_buf_compress(buf_t *buf, tor_compress_state_t *state,
const char *data, size_t data_len,
- int done)
+ const int done)
{
char *next;
size_t old_avail, avail;
@@ -2144,8 +2136,10 @@ write_to_buf_compress(buf_t *buf, tor_compress_state_t *state,
case TOR_COMPRESS_ERROR:
return -1;
case TOR_COMPRESS_OK:
- if (data_len == 0)
+ if (data_len == 0) {
+ tor_assert_nonfatal(!done);
over = 1;
+ }
break;
case TOR_COMPRESS_BUFFER_FULL:
if (avail) {
@@ -2154,6 +2148,11 @@ write_to_buf_compress(buf_t *buf, tor_compress_state_t *state,
* whether were going to or not. */
need_new_chunk = 1;
}
+ if (data_len == 0 && !done) {
+ /* We've consumed all the input data, though, so there's no
+ * point in forging ahead right now. */
+ over = 1;
+ }
break;
}
buf->datalen += old_avail - avail;