From: candychencan Date: Tue, 20 Sep 2016 18:27:15 +0000 (+0800) Subject: Fix strncpy in taskq_create X-Git-Tag: zfs-0.7.0-rc2~117 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d2a6f65cfb65ec3079f843542a156704264260be;p=zfs Fix strncpy in taskq_create 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 Signed-off-by: candychencan Closes #5136 --- diff --git a/lib/libzpool/taskq.c b/lib/libzpool/taskq.c index e42e4261f..c1f87e173 100644 --- a/lib/libzpool/taskq.c +++ b/lib/libzpool/taskq.c @@ -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;