Browse Source

Improve error msgs in tor-resolve.c; resolve bug 112

svn:r3947
Nick Mathewson 20 years ago
parent
commit
bc668233ad
2 changed files with 18 additions and 12 deletions
  1. 8 7
      doc/TODO
  2. 10 5
      src/tools/tor-resolve.c

+ 8 - 7
doc/TODO

@@ -42,21 +42,21 @@ N . Switch to libevent
          bandwidth buckets under heavy load.  (Really, the logic was
          bandwidth buckets under heavy load.  (Really, the logic was
          never right in the first place.)  Also, we should audit all users
          never right in the first place.)  Also, we should audit all users
          of get_pending_bytes().
          of get_pending_bytes().
-       . Find a way to make sure we have libevent 1.0 or later.
+       o Find a way to make sure we have libevent 1.0 or later.
          o Implement patch to libevent
          o Implement patch to libevent
          o Submit patch to niels making this possible.
          o Submit patch to niels making this possible.
-         - Implement Tor side once patch is accepted.
-       . Log which poll method we're using.
+         o Implement Tor side once patch is accepted.
+       o Log which poll method we're using.
          o Implement patch to libevent
          o Implement patch to libevent
          o Submit patch to niels making this possible.
          o Submit patch to niels making this possible.
-         - Implement Tor side once patch is accepted.
-       . Intercept libevent's "log" messages.
+         o Implement Tor side once patch is accepted.
+       o Intercept libevent's "log" messages.
          o Ask Niels whether a patch would be accepted.
          o Ask Niels whether a patch would be accepted.
          o Implement patch, if so.
          o Implement patch, if so.
-         - Implement Tor side once patch is accepted.
+         o Implement Tor side once patch is accepted.
        o Check return from event_set, event_add, event_del.
        o Check return from event_set, event_add, event_del.
        o Keep pushing to get a windows patch accepted.
        o Keep pushing to get a windows patch accepted.
-       - After about 26 March, check back with Niels; he should be back
+       o After about 26 March, check back with Niels; he should be back
          by then.
          by then.
 
 
  Security:
  Security:
@@ -181,6 +181,7 @@ R  o client software not upload descriptor until:
        * no need to do this yet. few people define their ORPort.
        * no need to do this yet. few people define their ORPort.
 
 
  Arguable
  Arguable
+N - tor-resolve script should use socks5 to get better error messages.
 N - Script to try pulling bytes through slow-seeming servers so they can
 N - Script to try pulling bytes through slow-seeming servers so they can
     notice that they might be fast.
     notice that they might be fast.
 N . Reverse DNS
 N . Reverse DNS

+ 10 - 5
src/tools/tor-resolve.c

@@ -74,15 +74,21 @@ parse_socks4a_resolve_response(const char *response, size_t len,
   tor_assert(response);
   tor_assert(response);
   tor_assert(addr_out);
   tor_assert(addr_out);
 
 
-  if (len < RESPONSE_LEN)
+  if (len < RESPONSE_LEN) {
+    log_fn(LOG_WARN,"Truncated socks response.");
     return -1;
     return -1;
-  if (((uint8_t)response[0])!=0) /* version: 0 */
+  }
+  if (((uint8_t)response[0])!=0) { /* version: 0 */
+    log_fn(LOG_WARN,"Nonzero version in socks response: bad format.");
     return -1;
     return -1;
+  }
   status = (uint8_t)response[1];
   status = (uint8_t)response[1];
-  if (get_uint16(response+2)!=0) /* port: 0 */
+  if (get_uint16(response+2)!=0) { /* port: 0 */
+    log_fn(LOG_WARN,"Nonzero port in socks response: bad format.");
     return -1;
     return -1;
+  }
   if (status != 90) {
   if (status != 90) {
-    log_fn(LOG_WARN,"Got status response '%d', meaning not success.", status);
+    log_fn(LOG_WARN,"Got status response '%d': socks request failed.", status);
     return -1;
     return -1;
   }
   }
 
 
@@ -151,7 +157,6 @@ do_resolve(const char *hostname, uint32_t sockshost, uint16_t socksport,
   }
   }
 
 
   if (parse_socks4a_resolve_response(response_buf, RESPONSE_LEN,result_addr)<0){
   if (parse_socks4a_resolve_response(response_buf, RESPONSE_LEN,result_addr)<0){
-    log_fn(LOG_ERR, "Error parsing SOCKS response");
     return -1;
     return -1;
   }
   }