diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2018-10-23 00:58:43 +0200 |
|---|---|---|
| committer | Paolo Bonzini <pbonzini@redhat.com> | 2018-11-06 21:35:05 +0100 |
| commit | 57dbb58d800f62b9e56d946660dba4e8dbd20204 (patch) | |
| tree | 6d71f68d85a5691af212dca8fc8c4c1c432c8e26 /hw/scsi/scsi-generic.c | |
| parent | 6c219fc8a112fc69b29f59ea2c7865717ff6e3e0 (diff) | |
| download | focaccia-qemu-57dbb58d800f62b9e56d946660dba4e8dbd20204.tar.gz focaccia-qemu-57dbb58d800f62b9e56d946660dba4e8dbd20204.zip | |
scsi-generic: avoid out-of-bounds access to VPD page list
A device can report an excessive number of VPD pages when asked for a list; this can cause an out-of-bounds access to buf in scsi_generic_set_vpd_bl_emulation. It should not happen, but it is technically not incorrect so handle it: do not check any byte past the allocation length that was sent to the INQUIRY command. Reported-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/scsi/scsi-generic.c')
| -rw-r--r-- | hw/scsi/scsi-generic.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index aebb7cdd82..c5497bbea8 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -538,7 +538,7 @@ static void scsi_generic_set_vpd_bl_emulation(SCSIDevice *s) } page_len = buf[3]; - for (i = 4; i < page_len + 4; i++) { + for (i = 4; i < MIN(sizeof(buf), page_len + 4); i++) { if (buf[i] == 0xb0) { s->needs_vpd_bl_emulation = false; return; |