[or-cvs] Improve error msgs in tor-resolve.c; resolve bug 112

Nick Mathewson nickm at seul.org
Fri Apr 1 07:03:47 UTC 2005


Update of /home/or/cvsroot/tor/src/tools
In directory moria.mit.edu:/tmp/cvs-serv32124/src/tools

Modified Files:
	tor-resolve.c 
Log Message:
Improve error msgs in tor-resolve.c; resolve bug 112

Index: tor-resolve.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/tools/tor-resolve.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- tor-resolve.c	22 Feb 2005 08:18:36 -0000	1.15
+++ tor-resolve.c	1 Apr 2005 07:03:44 -0000	1.16
@@ -74,15 +74,21 @@
   tor_assert(response);
   tor_assert(addr_out);
 
-  if (len < RESPONSE_LEN)
+  if (len < RESPONSE_LEN) {
+    log_fn(LOG_WARN,"Truncated socks response.");
     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;
+  }
   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;
+  }
   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;
   }
 
@@ -151,7 +157,6 @@
   }
 
   if (parse_socks4a_resolve_response(response_buf, RESPONSE_LEN,result_addr)<0){
-    log_fn(LOG_ERR, "Error parsing SOCKS response");
     return -1;
   }
 



More information about the tor-commits mailing list