]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
bridge: Always put transport-info line
authorDavid Goulet <dgoulet@torproject.org>
Tue, 11 Jun 2024 16:38:56 +0000 (12:38 -0400)
committerDavid Goulet <dgoulet@torproject.org>
Tue, 18 Jun 2024 19:15:32 +0000 (15:15 -0400)
Signed-off-by: David Goulet <dgoulet@torproject.org>
src/feature/client/transports.c
src/test/test_pt.c

index 403bedc18327f7e17693e6326786848daeffa940..878675ac4dc8c121841c55881786271481f84d9b 100644 (file)
@@ -1798,20 +1798,21 @@ pt_get_extra_info_descriptor_string(void)
 
     /* Set transport-info line. */
     {
-      char *transport_info_args = NULL;
+      char *version = NULL;
+      char *impl = NULL;
 
       if (mp->version) {
-        tor_asprintf(&transport_info_args, " version=%s", mp->version);
+        tor_asprintf(&version, " version=%s", mp->version);
       }
       if (mp->implementation) {
-        tor_asprintf(&transport_info_args, " implementation=%s",
-                     mp->implementation);
-      }
-      if (transport_info_args) {
-        smartlist_add_asprintf(string_chunks, "transport-info%s",
-                               transport_info_args ? transport_info_args : "");
-        tor_free(transport_info_args);
+        tor_asprintf(&impl, " implementation=%s", mp->implementation);
       }
+      /* Always put in the line even if empty. Else, we don't know to which
+       * transport this applies to. */
+      smartlist_add_asprintf(string_chunks, "transport-info%s%s",
+                             version ? version: "", impl ? impl: "");
+      tor_free(version);
+      tor_free(impl);
     }
   } SMARTLIST_FOREACH_END(mp);
 
index 62519a235ffb8a35a9e2bb195c8d5d14c6f3a4e5..10bf7829d17bfd1ef25f08cfbe638fca1e5dddaa 100644 (file)
@@ -413,7 +413,9 @@ test_pt_get_extrainfo_string(void *arg)
   tt_assert(s);
   tt_str_op(s, OP_EQ,
             "transport hagbard 127.0.0.1:5555\n"
-            "transport celine 127.0.0.1:1723 card=no-enemy\n");
+            "transport-info\n"
+            "transport celine 127.0.0.1:1723 card=no-enemy\n"
+            "transport-info\n");
 
  done:
   /* XXXX clean up better */