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.
This commit is contained in:
Robert Watson 2006-09-02 08:25:40 +00:00
parent 0ee913128d
commit ce105e8f5a

View file

@ -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)