]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add an assertion to num_ntors_per_tap().
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:44:10 +0000 (18:44 -0400)
This should please coverity, and fix CID 1415721.  It didn't
understand that networkstatus_get_param() always returns a value
between its minimum and maximum values.

src/feature/relay/onion_queue.c

index 696905cf5e7c41b2c2d53db10b9c42405054c829..c37745cf33afaea48233db086ca5167d6bf70095 100644 (file)
@@ -212,10 +212,12 @@ num_ntors_per_tap(void)
 #define MIN_NUM_NTORS_PER_TAP 1
 #define MAX_NUM_NTORS_PER_TAP 100000
 
-  return networkstatus_get_param(NULL, "NumNTorsPerTAP",
-                                 DEFAULT_NUM_NTORS_PER_TAP,
-                                 MIN_NUM_NTORS_PER_TAP,
-                                 MAX_NUM_NTORS_PER_TAP);
+  int result = networkstatus_get_param(NULL, "NumNTorsPerTAP",
+                                       DEFAULT_NUM_NTORS_PER_TAP,
+                                       MIN_NUM_NTORS_PER_TAP,
+                                       MAX_NUM_NTORS_PER_TAP);
+  tor_assert(result > 0);
+  return result;
 }
 
 /** Choose which onion queue we'll pull from next. If one is empty choose