diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-05-28 12:24:29 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-05-28 12:24:29 -0400 |
commit | a194385d5619f2b9c03ada34b8a7291ccc3c21ca (patch) | |
tree | e90a24a73b42e106adf06e877777785e6b8777f4 /src/common/workqueue.c | |
parent | 4a9f41e1eca32a8dbe53e1e4848e5f0d50c73731 (diff) | |
download | tor-a194385d5619f2b9c03ada34b8a7291ccc3c21ca.tar.gz tor-a194385d5619f2b9c03ada34b8a7291ccc3c21ca.zip |
Impose an upper limit on threads per threadpool.
Found by Coverity; Fixes CID 1268069
Diffstat (limited to 'src/common/workqueue.c')
-rw-r--r-- | src/common/workqueue.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/common/workqueue.c b/src/common/workqueue.c index c1bd6d4e8b..ed896d78d0 100644 --- a/src/common/workqueue.c +++ b/src/common/workqueue.c @@ -359,12 +359,17 @@ threadpool_queue_update(threadpool_t *pool, return 0; } +/** Don't have more than this many threads per pool. */ +#define MAX_THREADS 1024 + /** Launch threads until we have <b>n</b>. */ static int threadpool_start_threads(threadpool_t *pool, int n) { if (n < 0) return -1; + if (n > MAX_THREADS) + n = MAX_THREADS; tor_mutex_acquire(&pool->lock); |