Skip to content

Commit

Permalink
nvmet: use strlcpy() instead of strcpy()
Browse files Browse the repository at this point in the history
Although the code modified by this patch looks fine to me, this patch avoids
that Coverity reports the following complaint (ID 1364971 and ID 1364973):
"You might overrun the 256-character fixed-size string id->subnqn".

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Bart Van Assche authored and Christoph Hellwig committed Oct 17, 2018
1 parent 40581d1 commit 5eadc9c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/nvme/target/admin-cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
if (req->port->inline_data_size)
id->sgls |= cpu_to_le32(1 << 20);

strcpy(id->subnqn, ctrl->subsys->subsysnqn);
strlcpy(id->subnqn, ctrl->subsys->subsysnqn, sizeof(id->subnqn));

/* Max command capsule size is sqe + single page of in-capsule data */
id->ioccsz = cpu_to_le32((sizeof(struct nvme_command) +
Expand Down
2 changes: 1 addition & 1 deletion drivers/nvme/target/discovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static void nvmet_execute_identify_disc_ctrl(struct nvmet_req *req)
if (req->port->inline_data_size)
id->sgls |= cpu_to_le32(1 << 20);

strcpy(id->subnqn, ctrl->subsys->subsysnqn);
strlcpy(id->subnqn, ctrl->subsys->subsysnqn, sizeof(id->subnqn));

status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id));

Expand Down

0 comments on commit 5eadc9c

Please sign in to comment.