Re: [RFC v1 2/4] nvmet-trace: null terminate device name string correctly

Hannes Reinecke
2023-09-06T12:16:08Z

On 8/29/23 11:13, Daniel Wagner wrote:
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
> drivers/nvme/target/trace.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvme/target/trace.h b/drivers/nvme/target/trace.h
> index 6997bd7e45cf..9ba466b49613 100644
> --- a/drivers/nvme/target/trace.h
> +++ b/drivers/nvme/target/trace.h
> @@ -55,8 +55,8 @@ static inline void __assign_req_name(char *name, struct nvmet_req *req)
> return;
> }
>
> - strncpy(name, req->ns->device_path,
> - min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
> + strscpy(name, req->ns->device_path,
> + min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path) + 1));
> }
> #endif
>
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes