]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Impose an upper limit on threads per threadpool.
authorNick Mathewson <nickm@torproject.org>
Thu, 28 May 2015 16:24:29 +0000 (12:24 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 28 May 2015 16:24:29 +0000 (12:24 -0400)
Found by Coverity; Fixes CID 1268069

src/common/workqueue.c

index c1bd6d4e8b9a2912d7947723f5a485f533bc6eab..ed896d78d043e2b549f1bbab99e7e7b6b41fc439 100644 (file)
@@ -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);