diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-09-22 00:43:55 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-09-22 00:43:55 +0000 |
commit | 213658f117f88eaeb21ffd61451155f451f67604 (patch) | |
tree | 31f4c5d408f6372cc08d1be2731f4c2ab10eced9 /src/or/buffers.c | |
parent | 9bc8d69dfc4ddda5a9c8478b1f1e04490845ded0 (diff) | |
download | tor-213658f117f88eaeb21ffd61451155f451f67604.tar.gz tor-213658f117f88eaeb21ffd61451155f451f67604.zip |
r8894@Kushana: nickm | 2006-09-21 18:30:42 -0400
Specify and implement SOCKS5 interface for reverse hostname lookup.
svn:r8451
Diffstat (limited to 'src/or/buffers.c')
-rw-r--r-- | src/or/buffers.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c index b6e775da86..290a81c8b2 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -974,8 +974,9 @@ fetch_from_buf_socks(buf_t *buf, socks_request_t *req, return 0; /* not yet */ req->command = (unsigned char) *(buf->cur+1); if (req->command != SOCKS_COMMAND_CONNECT && - req->command != SOCKS_COMMAND_RESOLVE) { - /* not a connect or resolve? we don't support it. */ + req->command != SOCKS_COMMAND_RESOLVE && + req->command != SOCKS_COMMAND_RESOLVE_PTR) { + /* not a connect or resolve or a resolve_ptr? we don't support it. */ log_warn(LD_APP,"socks5: command %d not recognized. Rejecting.", req->command); return -1; @@ -999,7 +1000,8 @@ fetch_from_buf_socks(buf_t *buf, socks_request_t *req, strlcpy(req->address,tmpbuf,sizeof(req->address)); req->port = ntohs(*(uint16_t*)(buf->cur+8)); buf_remove_from_front(buf, 10); - if (!addressmap_have_mapping(req->address) && + if (req->command != SOCKS_COMMAND_RESOLVE_PTR && + !addressmap_have_mapping(req->address) && !have_warned_about_unsafe_socks) { log_warn(LD_APP, "Your application (using socks5 on port %d) is giving " @@ -1025,6 +1027,11 @@ fetch_from_buf_socks(buf_t *buf, socks_request_t *req, "%d. Rejecting.", len+1,MAX_SOCKS_ADDR_LEN); return -1; } + if (req->command == SOCKS_COMMAND_RESOLVE_PTR) { + log_warn(LD_APP, "socks5 received RESOLVE_PTR command with " + "hostname type. Rejecting."); + return -1; + } memcpy(req->address,buf->cur+5,len); req->address[len] = 0; req->port = ntohs(get_uint16(buf->cur+5+len)); @@ -1059,7 +1066,8 @@ fetch_from_buf_socks(buf_t *buf, socks_request_t *req, req->command = (unsigned char) *(buf->cur+1); if (req->command != SOCKS_COMMAND_CONNECT && req->command != SOCKS_COMMAND_RESOLVE) { - /* not a connect or resolve? we don't support it. */ + /* not a connect or resolve? we don't support it. (No resolve_ptr with + * socks4.) */ log_warn(LD_APP,"socks4: command %d not recognized. Rejecting.", req->command); return -1; |