[or-cvs] when an exit node gets a malformed begin cell, don"t compla...

arma at seul.org arma at seul.org
Thu Jul 6 02:44:08 UTC 2006


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

Modified Files:
	config.c connection.c connection_edge.c rendservice.c test.c 
Log Message:
when an exit node gets a malformed begin cell, don't complain to
the node operator, since he can't do anything about it.


Index: config.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.568
retrieving revision 1.569
diff -u -p -d -r1.568 -r1.569
--- config.c	4 Jul 2006 20:25:17 -0000	1.568
+++ config.c	6 Jul 2006 02:44:05 -0000	1.569
@@ -2040,7 +2040,7 @@ options_validate(or_options_t *old_optio
     for (line = options->SocksListenAddress; line; line = line->next) {
       uint16_t port;
       uint32_t addr;
-      if (parse_addr_port(line->value, &address, &addr, &port)<0)
+      if (parse_addr_port(LOG_WARN, line->value, &address, &addr, &port)<0)
         continue; /* We'll warn about this later. */
       if (!is_internal_IP(addr, 1) &&
           (!old_options || !config_lines_eq(old_options->SocksListenAddress,
@@ -2338,7 +2338,7 @@ options_validate(or_options_t *old_optio
     REJECT("Failed to parse accounting options. See logs for details.");
 
   if (options->HttpProxy) { /* parse it now */
-    if (parse_addr_port(options->HttpProxy, NULL,
+    if (parse_addr_port(LOG_WARN, options->HttpProxy, NULL,
                         &options->HttpProxyAddr, &options->HttpProxyPort) < 0)
       REJECT("HttpProxy failed to parse or resolve. Please fix.");
     if (options->HttpProxyPort == 0) { /* give it a default */
@@ -2352,7 +2352,7 @@ options_validate(or_options_t *old_optio
   }
 
   if (options->HttpsProxy) { /* parse it now */
-    if (parse_addr_port(options->HttpsProxy, NULL,
+    if (parse_addr_port(LOG_WARN, options->HttpsProxy, NULL,
                         &options->HttpsProxyAddr, &options->HttpsProxyPort) <0)
       REJECT("HttpsProxy failed to parse or resolve. Please fix.");
     if (options->HttpsProxyPort == 0) { /* give it a default */
@@ -3127,8 +3127,8 @@ parse_redirect_line(smartlist_t *result,
   if (0==strcasecmp(smartlist_get(elements,1), "pass")) {
     r->is_redirect = 0;
   } else {
-    if (parse_addr_port(smartlist_get(elements,1),NULL,&r->addr_dest,
-                             &r->port_dest)) {
+    if (parse_addr_port(LOG_WARN, smartlist_get(elements,1),NULL,
+                        &r->addr_dest, &r->port_dest)) {
       *msg = tor_strdup("Error parsing dest address in RedirectExit line");
       goto err;
     }
@@ -3193,7 +3193,7 @@ parse_dir_server_line(const char *line, 
     goto err;
   }
   addrport = smartlist_get(items, 0);
-  if (parse_addr_port(addrport, &address, NULL, &port)<0) {
+  if (parse_addr_port(LOG_WARN, addrport, &address, NULL, &port)<0) {
     log_warn(LD_CONFIG, "Error parsing DirServer address '%s'", addrport);
     goto err;
   }

Index: connection.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.457
retrieving revision 1.458
diff -u -p -d -r1.457 -r1.458
--- connection.c	18 Jun 2006 08:53:09 -0000	1.457
+++ connection.c	6 Jul 2006 02:44:05 -0000	1.458
@@ -522,7 +522,7 @@ connection_create_listener(const char *l
 #endif
 
   memset(&listenaddr,0,sizeof(struct sockaddr_in));
-  if (parse_addr_port(listenaddress, &address, &addr, &usePort)<0) {
+  if (parse_addr_port(LOG_WARN, listenaddress, &address, &addr, &usePort)<0) {
     log_warn(LD_CONFIG,
              "Error parsing/resolving ListenAddress %s", listenaddress);
     return NULL;
@@ -893,7 +893,7 @@ retry_listeners(int type, config_line_t 
       {
         char *address=NULL;
         uint16_t port;
-        if (! parse_addr_port(wanted->value, &address, NULL, &port)) {
+        if (!parse_addr_port(LOG_WARN, wanted->value, &address, NULL, &port)) {
           int addr_matches = !strcasecmp(address, conn->address);
           tor_free(address);
           if (! port)

Index: connection_edge.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection_edge.c,v
retrieving revision 1.401
retrieving revision 1.402
diff -u -p -d -r1.401 -r1.402
--- connection_edge.c	6 Jun 2006 00:06:52 -0000	1.401
+++ connection_edge.c	6 Jul 2006 02:44:06 -0000	1.402
@@ -1587,16 +1587,19 @@ connection_exit_begin_conn(cell_t *cell,
    */
 
   if (!memchr(cell->payload+RELAY_HEADER_SIZE, 0, rh.length)) {
-    log_warn(LD_PROTOCOL,"relay begin cell has no \\0. Dropping.");
+    log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
+           "Relay begin cell has no \\0. Dropping.");
     return 0;
   }
-  if (parse_addr_port(cell->payload+RELAY_HEADER_SIZE,&address,NULL,&port)<0) {
-    log_warn(LD_PROTOCOL,"Unable to parse addr:port in relay begin cell. "
-             "Dropping.");
+  if (parse_addr_port(LOG_PROTOCOL_WARN, cell->payload+RELAY_HEADER_SIZE,
+                      &address,NULL,&port)<0) {
+    log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
+           "Unable to parse addr:port in relay begin cell. Dropping.");
     return 0;
   }
   if (port==0) {
-    log_warn(LD_PROTOCOL,"Missing port in relay begin cell. Dropping.");
+    log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
+           "Missing port in relay begin cell. Dropping.");
     tor_free(address);
     return 0;
   }

Index: rendservice.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/rendservice.c,v
retrieving revision 1.161
retrieving revision 1.162
diff -u -p -d -r1.161 -r1.162
--- rendservice.c	4 Jun 2006 22:42:13 -0000	1.161
+++ rendservice.c	6 Jul 2006 02:44:06 -0000	1.162
@@ -179,7 +179,7 @@ parse_port_config(const char *string)
   } else {
     addrport = smartlist_get(sl,1);
     if (strchr(addrport, ':') || strchr(addrport, '.')) {
-      if (parse_addr_port(addrport, NULL, &addr, &p)<0) {
+      if (parse_addr_port(LOG_WARN, addrport, NULL, &addr, &p)<0) {
         log_warn(LD_CONFIG,"Unparseable address in hidden service port "
                  "configuration.");
         goto err;

Index: test.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/test.c,v
retrieving revision 1.230
retrieving revision 1.231
diff -u -p -d -r1.230 -r1.231
--- test.c	22 Jun 2006 07:34:04 -0000	1.230
+++ test.c	6 Jul 2006 02:44:06 -0000	1.231
@@ -807,27 +807,28 @@ test_util(void)
 
   /* Test parse_addr_port */
   cp = NULL; u32 = 3; u16 = 3;
-  test_assert(!parse_addr_port("1.2.3.4", &cp, &u32, &u16));
+  test_assert(!parse_addr_port(LOG_WARN, "1.2.3.4", &cp, &u32, &u16));
   test_streq(cp, "1.2.3.4");
   test_eq(u32, 0x01020304u);
   test_eq(u16, 0);
   tor_free(cp);
-  test_assert(!parse_addr_port("4.3.2.1:99", &cp, &u32, &u16));
+  test_assert(!parse_addr_port(LOG_WARN, "4.3.2.1:99", &cp, &u32, &u16));
   test_streq(cp, "4.3.2.1");
   test_eq(u32, 0x04030201u);
   test_eq(u16, 99);
   tor_free(cp);
-  test_assert(!parse_addr_port("nonexistent.address:4040", &cp, NULL, &u16));
+  test_assert(!parse_addr_port(LOG_WARN, "nonexistent.address:4040",
+                               &cp, NULL, &u16));
   test_streq(cp, "nonexistent.address");
   test_eq(u16, 4040);
   tor_free(cp);
-  test_assert(!parse_addr_port("localhost:9999", &cp, &u32, &u16));
+  test_assert(!parse_addr_port(LOG_WARN, "localhost:9999", &cp, &u32, &u16));
   test_streq(cp, "localhost");
   test_eq(u32, 0x7f000001u);
   test_eq(u16, 9999);
   tor_free(cp);
   u32 = 3;
-  test_assert(!parse_addr_port("localhost", NULL, &u32, &u16));
+  test_assert(!parse_addr_port(LOG_WARN, "localhost", NULL, &u32, &u16));
   test_eq(cp, NULL);
   test_eq(u32, 0x7f000001u);
   test_eq(u16, 0);



More information about the tor-commits mailing list