Skip to content

Commit

Permalink
Fix strncpy in taskq_create
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: candychencan <[email protected]>
Closes #5136
  • Loading branch information
candychencan authored and behlendorf committed Sep 20, 2016
1 parent 7925173 commit d2a6f65
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/libzpool/taskq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d2a6f65

Please sign in to comment.