]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix relay_command_to_string(); solve 12700.
authorNick Mathewson <nickm@torproject.org>
Mon, 18 Aug 2014 17:19:43 +0000 (13:19 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 18 Aug 2014 17:21:40 +0000 (13:21 -0400)
Two bugs here:
  1) We didn't add EXTEND2/EXTENDED2 to relay_command_to_string().

  2) relay_command_to_string() didn't log the value of unrecognized
     commands.

Both fixed here.

changes/bug12700 [new file with mode: 0644]
src/or/relay.c

diff --git a/changes/bug12700 b/changes/bug12700
new file mode 100644 (file)
index 0000000..1d8caeb
--- /dev/null
@@ -0,0 +1,10 @@
+  o Minor bugfixes:
+    - When logging information about an EXTEND2 or EXTENDED2 cell, log
+      their names correctly. Fixes part of bug 12700; bugfix on
+      0.2.4.8-alpha.
+
+  o Minor bugfixes:
+    - When logging information about a relay cell whose command we
+      don't recognize, log its command as an integer. Fixes part of
+      bug 12700; bugfix on 0.2.1.10-alpha.
+
index 7f06c6e14596fd421aa0f0a5601356479d4fcd0e..fffd45d52206f60d3ba1bded027a3a45906206d0 100644 (file)
@@ -517,6 +517,7 @@ relay_header_unpack(relay_header_t *dest, const uint8_t *src)
 static const char *
 relay_command_to_string(uint8_t command)
 {
+  static char buf[64];
   switch (command) {
     case RELAY_COMMAND_BEGIN: return "BEGIN";
     case RELAY_COMMAND_DATA: return "DATA";
@@ -541,7 +542,12 @@ relay_command_to_string(uint8_t command)
     case RELAY_COMMAND_RENDEZVOUS_ESTABLISHED:
       return "RENDEZVOUS_ESTABLISHED";
     case RELAY_COMMAND_INTRODUCE_ACK: return "INTRODUCE_ACK";
-    default: return "(unrecognized)";
+    case RELAY_COMMAND_EXTEND2: return "EXTEND2";
+    case RELAY_COMMAND_EXTENDED2: return "EXTENDED2";
+    default:
+      tor_snprintf(buf, sizeof(buf), "Unrecognized relay command %u",
+                   (unsigned)command);
+      return buf;
   }
 }