Procházet zdrojové kódy

prop224: Fix clang warnings

Signed-off-by: David Goulet <dgoulet@torproject.org>
David Goulet před 7 roky
rodič
revize
965e3a6628
2 změnil soubory, kde provedl 11 přidání a 2 odebrání
  1. 2 1
      src/or/hs_service.c
  2. 9 1
      src/or/rendservice.c

+ 2 - 1
src/or/hs_service.c

@@ -80,9 +80,10 @@ HT_GENERATE2(hs_service_ht, hs_service_t, hs_service_node,
 STATIC hs_service_t *
 find_service(hs_service_ht *map, const ed25519_public_key_t *pk)
 {
-  hs_service_t dummy_service = {0};
+  hs_service_t dummy_service;
   tor_assert(map);
   tor_assert(pk);
+  memset(&dummy_service, 0, sizeof(dummy_service));
   ed25519_pubkey_copy(&dummy_service.keys.identity_pk, pk);
   return HT_FIND(hs_service_ht, map, &dummy_service);
 }

+ 9 - 1
src/or/rendservice.c

@@ -18,6 +18,7 @@
 #include "control.h"
 #include "directory.h"
 #include "hs_common.h"
+#include "hs_config.h"
 #include "main.h"
 #include "networkstatus.h"
 #include "nodelist.h"
@@ -631,7 +632,14 @@ service_config_shadow_copy(rend_service_t *service,
   service->directory = tor_strdup(config->directory_path);
   service->dir_group_readable = config->dir_group_readable;
   service->allow_unknown_ports = config->allow_unknown_ports;
-  service->max_streams_per_circuit = config->max_streams_per_rdv_circuit;
+  /* This value can't go above HS_CONFIG_MAX_STREAMS_PER_RDV_CIRCUIT (65535)
+   * if the code flow is right so this cast is safe. But just in case, we'll
+   * check it. */
+  service->max_streams_per_circuit = (int) config->max_streams_per_rdv_circuit;
+  if (BUG(config->max_streams_per_rdv_circuit >
+          HS_CONFIG_MAX_STREAMS_PER_RDV_CIRCUIT)) {
+    service->max_streams_per_circuit = HS_CONFIG_MAX_STREAMS_PER_RDV_CIRCUIT;
+  }
   service->max_streams_close_circuit = config->max_streams_close_circuit;
   service->n_intro_points_wanted = config->num_intro_points;
   /* Switching ownership of the ports to the rend service object. */