t/memlock: Verify 'threads' argument
authorBart Van Assche <bvanassche@acm.org>
Sat, 11 Jan 2020 23:45:32 +0000 (15:45 -0800)
committerBart Van Assche <bvanassche@acm.org>
Sun, 12 Jan 2020 02:17:37 +0000 (18:17 -0800)
This patch fixes the following Coverity complaint:

CID 280681 (#1 of 1): Untrusted value as argument (TAINTED_SCALAR)
4. tainted_data: Passing tainted variable threads to a tainted sink.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
t/memlock.c

index ebedb91d4eb67417563fd4e969e52d6b9bf3feec..418dc3c48fd0c1b4cf8596564ee22f3f661fd92a 100644 (file)
@@ -43,6 +43,10 @@ int main(int argc, char *argv[])
 
        mib = strtoul(argv[1], NULL, 10);
        threads = strtoul(argv[2], NULL, 10);
+       if (threads < 1 || threads > 65536) {
+               printf("%s: invalid 'threads' argument\n", argv[0]);
+               return 1;
+       }
 
        pthreads = calloc(threads, sizeof(pthread_t));
        td.mib = mib;