]> granicus.if.org Git - zfs/commitdiff
Fix strncpy in taskq_create
authorcandychencan <chen.can2@zte.com.cn>
Tue, 20 Sep 2016 18:27:15 +0000 (02:27 +0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 20 Sep 2016 18:27:15 +0000 (11:27 -0700)
Assign the copy length to TASKQ_NAMELEN, so if the name length equals
'TASKQ_NAMELEN+1' , the final '\0' of tq->tq_name is preserved.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: candychencan <chen.can2@zte.com.cn>
Closes #5136

lib/libzpool/taskq.c

index e42e4261f8d7f413c9d49ae8aa1314d20b2c3c28..c1f87e173d19d76e6aaca70edf08fe44d243bd67 100644 (file)
@@ -268,7 +268,7 @@ taskq_create(const char *name, int nthreads, pri_t pri,
        cv_init(&tq->tq_dispatch_cv, NULL, CV_DEFAULT, NULL);
        cv_init(&tq->tq_wait_cv, NULL, CV_DEFAULT, NULL);
        cv_init(&tq->tq_maxalloc_cv, NULL, CV_DEFAULT, NULL);
-       (void) strncpy(tq->tq_name, name, TASKQ_NAMELEN + 1);
+       (void) strncpy(tq->tq_name, name, TASKQ_NAMELEN);
        tq->tq_flags = flags | TASKQ_ACTIVE;
        tq->tq_active = nthreads;
        tq->tq_nthreads = nthreads;