nvme: compare NQN string with right size
authorJavier González <jg@lightnvm.io>
Wed, 8 Nov 2017 09:59:03 +0000 (10:59 +0100)
committerJens Axboe <axboe@kernel.dk>
Sat, 11 Nov 2017 02:53:25 +0000 (19:53 -0700)
Copy subnqns using NVMF_NQN_SIZE as it is < 256

Signed-off-by: Javier González <javier@cnexlabs.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/host/core.c

index 65fd2fc1ae3c20878fdbe5911be7ac7bee18801f..8a60cc786220bfc7227e23cb548f9073d6e98340 100644 (file)
@@ -1810,7 +1810,7 @@ static void nvme_init_subnqn(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
 
        nqnlen = strnlen(id->subnqn, NVMF_NQN_SIZE);
        if (nqnlen > 0 && nqnlen < NVMF_NQN_SIZE) {
-               strcpy(ctrl->subnqn, id->subnqn);
+               strncpy(ctrl->subnqn, id->subnqn, NVMF_NQN_SIZE);
                return;
        }