From a084a703df9ab896c9d30ac479e1388e5e4cafb0 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 9 Aug 2012 13:34:53 +0200 Subject: [PATCH] scsi-disk: improve out-of-range LBA detection for WRITE SAME Signed-off-by: Paolo Bonzini --- hw/scsi-disk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 9af9d18fad..584aec13fb 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -1712,7 +1712,8 @@ static int32_t scsi_disk_emulate_command(SCSIRequest *req, uint8_t *buf) scsi_check_condition(r, SENSE_CODE(WRITE_PROTECTED)); return 0; } - if (r->req.cmd.lba > s->qdev.max_lba) { + if (r->req.cmd.lba > r->req.cmd.lba + nb_sectors || + r->req.cmd.lba + nb_sectors - 1 > s->qdev.max_lba) { goto illegal_lba; }