From 215b44e9d41b018df1051af07e3212d363bc5b46 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 10 Nov 2018 17:47:38 +0000 Subject: [PATCH] scst/src/dev_handlers/scst_vdisk.c: Avoid that Coverity complains about an out-of-bounds access git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7806 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index eaa3236a3..431d947b5 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -3857,7 +3857,8 @@ static int vdisk_usn_vpd(uint8_t *buf, struct scst_cmd *cmd, } else { read_lock(&vdisk_serial_rwlock); usn_len = strlen(virt_dev->usn); - WARN_ON_ONCE(usn_len > max_len); + if (WARN_ON_ONCE(usn_len > max_len)) + usn_len = max_len; memcpy(&buf[4], virt_dev->usn, usn_len); read_unlock(&vdisk_serial_rwlock); }