]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add an assertion to pathbias_get_scale_ratio()
authorNick Mathewson <nickm@torproject.org>
Thu, 11 Apr 2019 22:38:59 +0000 (18:38 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 11 Apr 2019 22:38:59 +0000 (18:38 -0400)
This should please coverity, and fix CID 1415723.  It didn't understand
that networkstatus_get_param() always returns a value between its
minimum and maximum values.

src/feature/client/circpathbias.c

index 1743ab5a8174f7db793918b4d5631d0fe4f25458..e6af649ba7c6ef3b63e4416c88671a4723fecda9 100644 (file)
@@ -176,6 +176,7 @@ pathbias_get_scale_threshold(const or_options_t *options)
 static double
 pathbias_get_scale_ratio(const or_options_t *options)
 {
+  (void) options;
   /*
    * The scale factor is the denominator for our scaling
    * of circuit counts for our path bias window.
@@ -185,7 +186,8 @@ pathbias_get_scale_ratio(const or_options_t *options)
    */
   int denominator = networkstatus_get_param(NULL, "pb_scalefactor",
                               2, 2, INT32_MAX);
-  (void) options;
+  tor_assert(denominator > 0);
+
   /**
    * The mult factor is the numerator for our scaling
    * of circuit counts for our path bias window. It