]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Never pick a rate of 0.
authorNick Mathewson <nickm@torproject.org>
Fri, 13 Apr 2018 15:38:57 +0000 (11:38 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 13 Apr 2018 20:31:47 +0000 (16:31 -0400)
(The tests caught this one.)

src/common/token_bucket.c

index 1ac1bd6d3cdc8adcc0e7cb14412f2d3c7e484d71..abfcc680c46f0aa6059d9324f8422521f940c69b 100644 (file)
@@ -76,8 +76,9 @@ rate_per_sec_to_rate_per_step(uint32_t rate)
     (rate / 1000) * to_approximate_msec(TICKS_PER_STEP).  But to minimize
     rounding error, we do it this way instead, and divide last.
   */
-  return (uint32_t)
+  uint32_t val = (uint32_t)
     monotime_coarse_stamp_units_to_approx_msec(rate*TICKS_PER_STEP)/1000;
+  return val ? val : 1;
 }
 
 /**