From ce105e8f5a7d8a0bef2b76a3284d528fb24fd46d Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Sat, 2 Sep 2006 08:25:40 +0000 Subject: [PATCH] Enforce the compile-time threads limit at run-time, so that a high thread count argument doesn't cause a segfault or memory corruption when the compile-time array is overrun. --- tools/tools/netrate/http/http.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/tools/netrate/http/http.c b/tools/tools/netrate/http/http.c index c712d954783..5010703b183 100644 --- a/tools/tools/netrate/http/http.c +++ b/tools/tools/netrate/http/http.c @@ -273,6 +273,10 @@ main(int argc, char *argv[]) if (argc != 3) usage(); + if (numthreads > MAXTHREADS) + errx(-1, "%d exceeds max threads %d", numthreads, + MAXTHREADS); + len = roundup(sizeof(struct state), getpagesize()); pagebuffer = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); if (pagebuffer == MAP_FAILED)