From c71eccfb10023bc6001fed1aa4831f1f5c5c9416 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 14 Aug 2015 10:57:51 +0900 Subject: [PATCH] Remove MAX_THREADS. This fixes a buffer overflow with more than 4 threads. --- tools/qfvis/source/qfvis.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/qfvis/source/qfvis.c b/tools/qfvis/source/qfvis.c index 020d80723..7ec7e776c 100644 --- a/tools/qfvis/source/qfvis.c +++ b/tools/qfvis/source/qfvis.c @@ -60,8 +60,6 @@ #include "vis.h" #include "options.h" -#define MAX_THREADS 4 - #ifdef USE_PTHREADS pthread_attr_t threads_attrib; pthread_rwlock_t *global_lock; @@ -528,11 +526,12 @@ static void RunThreads (void *(*thread_func) (void *)) { #ifdef USE_PTHREADS - pthread_t work_threads[MAX_THREADS + 1]; + pthread_t *work_threads; void *status; int i; if (options.threads > 1) { + work_threads = alloca ((options.threads + 1) * sizeof (pthread_t *)); working = calloc (options.threads, sizeof (int)); for (i = 0; i < options.threads; i++) { if (pthread_create (&work_threads[i], &threads_attrib,