From e3c8aedb2caecad5410e83c4f5bd80a5760274ec Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 21 Dec 2020 23:58:29 +0000 Subject: [PATCH] scst_event: Fix the code that copies the CDB of the command to be aborted I came across this accidentally while looking up the users of the cmd_to_abort pointer. Fixes: 297d268a7a0d ("SCST events infrastructure"; r6574) git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9230 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_event.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scst/src/scst_event.c b/scst/src/scst_event.c index f86e5ca4e..724a0e712 100644 --- a/scst/src/scst_event.c +++ b/scst/src/scst_event.c @@ -472,8 +472,9 @@ int scst_event_queue_tm_fn_received(struct scst_mgmt_cmd *mcmd) sizeof(payload->session_sysfs_name)); if (mcmd->cmd_to_abort != NULL) { payload->cmd_to_abort_tag = mcmd->cmd_to_abort->tag; - strlcpy(payload->cdb, mcmd->cmd_to_abort->cdb, - sizeof(payload->cdb)); + memcpy(payload->cdb, mcmd->cmd_to_abort->cdb, + min_t(u32, mcmd->cmd_to_abort->cdb_len, + sizeof(payload->cdb))); } scst_event_queue(SCST_EVENT_TM_FN_RECEIVED,