summaryrefslogtreecommitdiff
path: root/src/or/buffers.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2006-03-15 23:36:57 +0000
committerRoger Dingledine <arma@torproject.org>2006-03-15 23:36:57 +0000
commit9a5df4cef51c33e92ecf924f66f5c794e6607ccf (patch)
treedab5c8bb80deeceb32d83afcc76d7d6a7cc0b4de /src/or/buffers.c
parent0e62befab8e4ece2f7b80a2755b7fb36521f5fe0 (diff)
downloadtor-9a5df4cef51c33e92ecf924f66f5c794e6607ccf.tar.gz
tor-9a5df4cef51c33e92ecf924f66f5c794e6607ccf.zip
resume being printist: if the hostname contains non-printable
characters, then fail. this time don't even bother telling the server operator about these cases, because what's he going to do? if it turns out that some significant population somewhere in the world uses non-printable hostnames and wants to use tor, then i hereby assume that they will contact us. svn:r6171
Diffstat (limited to 'src/or/buffers.c')
-rw-r--r--src/or/buffers.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index 4bba6423d4..f07dc7d233 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -1003,7 +1003,13 @@ fetch_from_buf_socks(buf_t *buf, socks_request_t *req, int log_sockstype)
req->address[len] = 0;
req->port = ntohs(get_uint16(buf->cur+5+len));
buf_remove_from_front(buf, 5+len+2);
-
+ if (!tor_strisprint(req->address) || strchr(req->address,'\"')) {
+ log_warn(LD_PROTOCOL,
+ "Your application (using socks5 on port %d) gave Tor "
+ "a malformed hostname: %s. Rejecting the connection.",
+ req->port, escaped(req->address));
+ return -1;
+ }
if (log_sockstype)
log_notice(LD_APP,
"Your application (using socks5 on port %d) gave "
@@ -1098,6 +1104,13 @@ fetch_from_buf_socks(buf_t *buf, socks_request_t *req, int log_sockstype)
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,'\"')) {
+ log_warn(LD_PROTOCOL,
+ "Your application (using socks4 on port %d) gave Tor "
+ "a malformed hostname: %s. Rejecting the connection.",
+ req->port, escaped(req->address));
+ return -1;
+ }
/* next points to the final \0 on inbuf */
buf_remove_from_front(buf, next-buf->cur+1);
return 1;