aboutsummaryrefslogtreecommitdiff
path: root/hw/scsi-disk.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-08-09 13:34:53 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2012-08-09 15:35:45 +0200
commita084a703df9ab896c9d30ac479e1388e5e4cafb0 (patch)
tree2c5234d59101515c8180a6ea9d541d6da97df0f0 /hw/scsi-disk.c
parent46e3f30e3c81e23c07f16b2193dfb6928646c205 (diff)
scsi-disk: improve out-of-range LBA detection for WRITE SAME
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/scsi-disk.c')
-rw-r--r--hw/scsi-disk.c3
1 files changed, 2 insertions, 1 deletions
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;
}