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

[tor-commits] [tor/master] sched: validate KIST sched options



commit 7f1d6430833a15a1ec806f9d17babc7d653b08ac
Author: Matt Traudt <sirmatt@xxxxxxx>
Date:   Wed Sep 13 12:47:02 2017 -0400

    sched: validate KIST sched options
---
 src/or/config.c         | 13 +++++++++++++
 src/or/scheduler.h      | 14 ++++++++++++++
 src/or/scheduler_kist.c |  7 -------
 3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/src/or/config.c b/src/or/config.c
index 285d4952f..f332ac97f 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -3112,6 +3112,19 @@ options_validate(or_options_t *old_options, or_options_t *options,
     routerset_union(options->ExcludeExitNodesUnion_,options->ExcludeNodes);
   }
 
+  if (options->KISTSockBufSizeFactor < 0) {
+    REJECT("KISTSockBufSizeFactor must be at least 0");
+  }
+  /* Don't need to validate that the Interval is less than anything because
+   * zero is valid and all negative values are valid. */
+  if (options->KISTSchedRunInterval > KIST_SCHED_RUN_INTERVAL_MAX) {
+    char *buf = tor_calloc(80, sizeof(char));
+    tor_snprintf(buf, 80, "KISTSchedRunInterval must not be more than %d (ms)",
+                 KIST_SCHED_RUN_INTERVAL_MAX);
+    *msg = buf;
+    return -1;
+  }
+
   if (options->NodeFamilies) {
     options->NodeFamilySets = smartlist_new();
     for (cl = options->NodeFamilies; cl; cl = cl->next) {
diff --git a/src/or/scheduler.h b/src/or/scheduler.h
index 6cf75c585..0d8235273 100644
--- a/src/or/scheduler.h
+++ b/src/or/scheduler.h
@@ -83,6 +83,20 @@ typedef struct scheduler_s {
 } scheduler_t;
 
 /*****************************************************************************
+ * Globally visible scheduler variables/values
+ *
+ * These are variables/constants that all of Tor should be able to see.
+ *****************************************************************************/
+
+/* Default interval that KIST runs (in ms). */
+#define KIST_SCHED_RUN_INTERVAL_DEFAULT 10
+/* Minimum interval that KIST runs. This value disables KIST. */
+#define KIST_SCHED_RUN_INTERVAL_MIN 0
+/* Maximum interval that KIST runs (in ms). */
+#define KIST_SCHED_RUN_INTERVAL_MAX 100
+
+
+/*****************************************************************************
  * Globally visible scheduler functions
  *
  * These functions are how the rest of Tor communicates with the scheduling
diff --git a/src/or/scheduler_kist.c b/src/or/scheduler_kist.c
index d3b19fdd1..3c3d26ad5 100644
--- a/src/or/scheduler_kist.c
+++ b/src/or/scheduler_kist.c
@@ -623,13 +623,6 @@ get_kist_scheduler(void)
   return kist_scheduler;
 }
 
-/* Default interval that KIST runs (in ms). */
-#define KIST_SCHED_RUN_INTERVAL_DEFAULT 10
-/* Minimum interval that KIST runs. This value disables KIST. */
-#define KIST_SCHED_RUN_INTERVAL_MIN 0
-/* Maximum interval that KIST runs (in ms). */
-#define KIST_SCHED_RUN_INTERVAL_MAX 100
-
 /* Check the torrc for the configured KIST scheduler run interval.
  * - If torrc < 0, then return the negative torrc value (shouldn't even be
  *   using KIST)



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