Commit 8f70328c authored by Javed Hasan's avatar Javed Hasan Committed by Martin K. Petersen

scsi: libfc: Correct the condition check and invalid argument passed

Incorrect condition check was leading to data corruption.

Link: https://lore.kernel.org/r/20210603101404.7841-3-jhasan@marvell.com
Fixes: 8fd9efca ("scsi: libfc: Work around -Warray-bounds warning")
CC: stable@vger.kernel.org
Reviewed-by: default avatarHimanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: default avatarJaved Hasan <jhasan@marvell.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 40445fd2
......@@ -166,9 +166,11 @@ static inline int fc_ct_ns_fill(struct fc_lport *lport,
static inline void fc_ct_ms_fill_attr(struct fc_fdmi_attr_entry *entry,
const char *in, size_t len)
{
int copied = strscpy(entry->value, in, len);
if (copied > 0)
memset(entry->value, copied, len - copied);
int copied;
copied = strscpy((char *)&entry->value, in, len);
if (copied > 0 && (copied + 1) < len)
memset((entry->value + copied + 1), 0, len - copied - 1);
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment