]> Git Repo - qemu.git/commitdiff
iscsi: Don't blindly use designator length in response for memcpy
authorFam Zheng <[email protected]>
Fri, 29 Jun 2018 06:03:27 +0000 (14:03 +0800)
committerKevin Wolf <[email protected]>
Fri, 29 Jun 2018 12:20:56 +0000 (14:20 +0200)
Per SCSI definition the designator_length we receive from INQUIRY is 8,
12 or at most 16, but we should be careful because the remote iscsi
target may misbehave, otherwise we could have a buffer overflow.

Reported-by: Max Reitz <[email protected]>
Signed-off-by: Fam Zheng <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
block/iscsi.c

index bc84b14e20f372dd120a0c42a89f7366b978810a..9beb06d498608bc36fa826ee9d8d85146dc449c6 100644 (file)
@@ -2226,7 +2226,7 @@ static void iscsi_populate_target_desc(unsigned char *desc, IscsiLun *lun)
     desc[5] = (dd->designator_type & 0xF)
         | ((dd->association & 3) << 4);
     desc[7] = dd->designator_length;
-    memcpy(desc + 8, dd->designator, dd->designator_length);
+    memcpy(desc + 8, dd->designator, MIN(dd->designator_length, 20));
 
     desc[28] = 0;
     desc[29] = (lun->block_size >> 16) & 0xFF;
This page took 0.022741 seconds and 4 git commands to generate.