Selaa lähdekoodia

Fix a bug in ADDRMAP controller replies that would sometimes
try to print a NULL. Patch from tup.


svn:r11181

Roger Dingledine 18 vuotta sitten
vanhempi
commit
c88803d924
3 muutettua tiedostoa jossa 12 lisäystä ja 6 poistoa
  1. 2 0
      ChangeLog
  2. 7 3
      doc/spec/control-spec.txt
  3. 3 3
      src/or/control.c

+ 2 - 0
ChangeLog

@@ -65,6 +65,8 @@ Changes in version 0.2.0.5-alpha - 2007-08-19
     - Fix a bug with AutomapHostsOnResolve that would always cause
     - Fix a bug with AutomapHostsOnResolve that would always cause
       the second request to fail. Bug reported by Kate. Bugfix on
       the second request to fail. Bug reported by Kate. Bugfix on
       0.2.0.3-alpha.
       0.2.0.3-alpha.
+    - Fix a bug in ADDRMAP controller replies that would sometimes
+      try to print a NULL. Patch from tup.
     - Read v3 directory authority keys from the right location.
     - Read v3 directory authority keys from the right location.
     - Numerous bugfixes to directory voting code.
     - Numerous bugfixes to directory voting code.
 
 

+ 7 - 3
doc/spec/control-spec.txt

@@ -762,7 +762,7 @@ $Id$
     PIVERSION: 1*DIGIT
     PIVERSION: 1*DIGIT
 
 
   Tor MAY give its InfoLines in any order; controllers MUST ignore InfoLines
   Tor MAY give its InfoLines in any order; controllers MUST ignore InfoLines
-  with keywords it does not recognize.  Controllers MUST ignore extraneous
+  with keywords they do not recognize.  Controllers MUST ignore extraneous
   data on any InfoLine.
   data on any InfoLine.
 
 
   PIVERSION is there in case we drastically change the syntax one day. For
   PIVERSION is there in case we drastically change the syntax one day. For
@@ -1044,10 +1044,14 @@ $Id$
 4.1.7. New Address mapping
 4.1.7. New Address mapping
 
 
   Syntax:
   Syntax:
-     "650" SP "ADDRMAP" SP Address SP Address SP Expiry SP Error SP GMTExpiry
+     "650" SP "ADDRMAP" SP Address SP NewAddress SP Expiry
+       [SP Error] SP GMTExpiry CRLF
+
+     NewAddress = Address / "<error>"
      Expiry = DQUOTE ISOTime DQUOTE / "NEVER"
      Expiry = DQUOTE ISOTime DQUOTE / "NEVER"
 
 
-     Error = / "error=" ErrorCode
+     Error = "error=" ErrorCode
+     ErrorCode = XXXX
      GMTExpiry = "EXPIRES=" DQUOTE IsoTime DQUOTE
      GMTExpiry = "EXPIRES=" DQUOTE IsoTime DQUOTE
 
 
   Error and GMTExpiry are only provided if extended events are enabled.
   Error and GMTExpiry are only provided if extended events are enabled.

+ 3 - 3
src/or/control.c

@@ -3174,7 +3174,7 @@ control_event_descriptors_changed(smartlist_t *routers)
 
 
 /** Called whenever an address mapping on <b>from<b> from changes to <b>to</b>.
 /** Called whenever an address mapping on <b>from<b> from changes to <b>to</b>.
  * <b>expires</b> values less than 3 are special; see connection_edge.c.  If
  * <b>expires</b> values less than 3 are special; see connection_edge.c.  If
- * <b>error</b> is nonempty, it is an error code describing the failure
+ * <b>error</b> is non-NULL, it is an error code describing the failure
  * mode of the mapping.
  * mode of the mapping.
  */
  */
 int
 int
@@ -3187,7 +3187,7 @@ control_event_address_mapped(const char *from, const char *to, time_t expires,
   if (expires < 3 || expires == TIME_MAX)
   if (expires < 3 || expires == TIME_MAX)
     send_control_event_extended(EVENT_ADDRMAP, ALL_NAMES,
     send_control_event_extended(EVENT_ADDRMAP, ALL_NAMES,
                                 "650 ADDRMAP %s %s NEVER@%s\r\n", from, to,
                                 "650 ADDRMAP %s %s NEVER@%s\r\n", from, to,
-                                error);
+                                error?error:"");
   else {
   else {
     char buf[ISO_TIME_LEN+1];
     char buf[ISO_TIME_LEN+1];
     char buf2[ISO_TIME_LEN+1];
     char buf2[ISO_TIME_LEN+1];
@@ -3197,7 +3197,7 @@ control_event_address_mapped(const char *from, const char *to, time_t expires,
                                 "650 ADDRMAP %s %s \"%s\""
                                 "650 ADDRMAP %s %s \"%s\""
                                 "@%s%sEXPIRES=\"%s\"\r\n",
                                 "@%s%sEXPIRES=\"%s\"\r\n",
                                 from, to, buf,
                                 from, to, buf,
-                                error, error?" ":"",
+                                error?error:"", error?" ":"",
                                 buf2);
                                 buf2);
   }
   }