xen-pt: fix Out-of-bounds read
authorGonglei <arei.gonglei@huawei.com>
Tue, 10 Feb 2015 07:51:23 +0000 (15:51 +0800)
committerMichael Tokarev <mjt@tls.msk.ru>
Tue, 10 Mar 2015 05:15:33 +0000 (08:15 +0300)
The array length of s->real_device.io_regions[] is
"PCI_NUM_REGIONS - 1".

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
hw/xen/xen_pt_config_init.c

index 710fe50..d99c22e 100644 (file)
@@ -438,7 +438,7 @@ static int xen_pt_bar_reg_read(XenPCIPassthroughState *s, XenPTReg *cfg_entry,
 
     /* get BAR index */
     index = xen_pt_bar_offset_to_index(reg->offset);
-    if (index < 0 || index >= PCI_NUM_REGIONS) {
+    if (index < 0 || index >= PCI_NUM_REGIONS - 1) {
         XEN_PT_ERR(&s->dev, "Internal error: Invalid BAR index [%d].\n", index);
         return -1;
     }