diff options
author | rwatson <rwatson@FreeBSD.org> | 2006-09-02 08:25:40 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2006-09-02 08:25:40 +0000 |
commit | ecf4fc184b0357d89bd6b9c384cb9c8fa6ff492f (patch) | |
tree | c6ab35a1e160b8778ad9bf3d7948212e407f5e22 /tools | |
parent | 4f2dba52bb6a57dd318e85de5cb5dfa2edc525c8 (diff) | |
download | FreeBSD-src-ecf4fc184b0357d89bd6b9c384cb9c8fa6ff492f.zip FreeBSD-src-ecf4fc184b0357d89bd6b9c384cb9c8fa6ff492f.tar.gz |
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.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/tools/netrate/http/http.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/tools/netrate/http/http.c b/tools/tools/netrate/http/http.c index c712d95..5010703 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) |