[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/maint-0.4.6] hs-v2: Disable version 2 HSPOST and HSFETCH command



commit ef7a64e3b874231f6793b563ea36b512ba072c5b
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date:   Thu Sep 30 10:59:24 2021 -0400

    hs-v2: Disable version 2 HSPOST and HSFETCH command
    
    Part of #40476
    
    Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
 src/feature/control/control.c | 32 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/src/feature/control/control.c b/src/feature/control/control.c
index 8185218a9f..c873d59f5e 100644
--- a/src/feature/control/control.c
+++ b/src/feature/control/control.c
@@ -4406,12 +4406,10 @@ handle_control_hsfetch(control_connection_t *conn, uint32_t len,
                        const char *body)
 {
   int i;
-  char digest[DIGEST_LEN], *hsaddress = NULL, *arg1 = NULL, *desc_id = NULL;
+  char *hsaddress = NULL, *arg1 = NULL, *desc_id = NULL;
   smartlist_t *args = NULL, *hsdirs = NULL;
   (void) len; /* body is nul-terminated; it's safe to ignore the length */
   static const char *hsfetch_command = "HSFETCH";
-  static const char *v2_str = "v2-";
-  const size_t v2_str_len = strlen(v2_str);
   rend_data_t *rend_query = NULL;
 
   /* Make sure we have at least one argument, the HSAddress. */
@@ -4422,21 +4420,13 @@ handle_control_hsfetch(control_connection_t *conn, uint32_t len,
 
   /* Extract the first argument (either HSAddress or DescID). */
   arg1 = smartlist_get(args, 0);
-  /* Test if it's an HS address without the .onion part. */
-  if (rend_valid_v2_service_id(arg1)) {
-    hsaddress = arg1;
-  } else if (strcmpstart(arg1, v2_str) == 0 &&
-             rend_valid_descriptor_id(arg1 + v2_str_len) &&
-             base32_decode(digest, sizeof(digest), arg1 + v2_str_len,
-                           REND_DESC_ID_V2_LEN_BASE32) == 0) {
-    /* We have a well formed version 2 descriptor ID. Keep the decoded value
-     * of the id. */
-    desc_id = digest;
-  } else {
-    connection_printf_to_buf(conn, "513 Invalid argument \"%s\"\r\n",
-                             arg1);
-    goto done;
-  }
+
+  /* We no longer support version 2 on the network and so immediately return an
+   * error. We do this in order to not remove the code so to minimize the merge
+   * forward conflicts. */
+  connection_printf_to_buf(conn, "513 Invalid argument \"%s\"\r\n",
+                           arg1);
+  goto done;
 
   static const char *opt_server = "SERVER=";
 
@@ -4575,9 +4565,13 @@ handle_control_hspost(control_connection_t *conn,
       send_control_done(conn);
     }
     tor_free(desc_str);
-    goto done;
   }
 
+  /* As for HSFETCH, we no longer support v2 on the network and so we stop
+   * right now. Code is not removed in order to minimize the merge forward
+   * conflicts. */
+  goto done;
+
   /* From this point on, it is only v2. */
 
   /* Read the dot encoded descriptor, and parse it. */



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits