From: Nick Mathewson Date: Thu, 28 May 2015 16:24:29 +0000 (-0400) Subject: Impose an upper limit on threads per threadpool. X-Git-Tag: tor-0.2.7.2-alpha~135 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a194385d5619f2b9c03ada34b8a7291ccc3c21ca;p=thirdparty%2Ftor.git Impose an upper limit on threads per threadpool. Found by Coverity; Fixes CID 1268069 --- 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 n. */ 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);