[or-cvs] let is_internal_IP() know whether you"re asking about an IP

arma at seul.org arma at seul.org
Fri Dec 9 02:45:35 UTC 2005


Update of /home2/or/cvsroot/tor/src/common
In directory moria:/home/arma/work/onion/cvs/tor/src/common

Modified Files:
	util.c 
Log Message:
let is_internal_IP() know whether you're asking about an IP
address for connecting or an IP address for binding, because
in the latter, 0.0.0.0 is a special case.


Index: util.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/common/util.c,v
retrieving revision 1.238
retrieving revision 1.239
diff -u -d -r1.238 -r1.239
--- util.c	8 Dec 2005 04:01:37 -0000	1.238
+++ util.c	9 Dec 2005 02:45:33 -0000	1.239
@@ -1304,8 +1304,10 @@
  * or reserved for local networks by RFC 1918.
  */
 int
-is_internal_IP(uint32_t ip)
+is_internal_IP(uint32_t ip, int for_listening)
 {
+  if (for_listening && !ip) /* special case for binding to 0.0.0.0 */
+    return 0;
   if (((ip & 0xff000000) == 0x0a000000) || /*       10/8 */
       ((ip & 0xff000000) == 0x00000000) || /*        0/8 */
       ((ip & 0xff000000) == 0x7f000000) || /*      127/8 */
@@ -1324,7 +1326,7 @@
 int
 is_local_IP(uint32_t ip)
 {
-  return is_internal_IP(ip);
+  return is_internal_IP(ip, 0);
 }
 
 /** Parse a string of the form "host[:port]" from <b>addrport</b>.  If



More information about the tor-commits mailing list