ia64/xen-unstable

changeset 12581:f711b87ba951

[QEMU] fdc: Limit sector size to 16K

In fdctrl_start_transfer the sector size field (fifo[5]) is not
checked for overflows. This allows an arbitrarily large sector size
to be used, which can in turn result in a negative data_len field that
is then used for DMA transfers.

This can lead to the corrpuption of qemu state because some subsequent
checks on the transfer length is conducted using signed integers.

This patch limits the value fifo[5] to 7 which is the standard limit
on floppy sector size.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
author kfraser@localhost.localdomain
date Mon Nov 27 10:09:19 2006 +0000 (2006-11-27)
parents f3ee62b7fb52
children 8795be1653c9
files tools/ioemu/hw/fdc.c
line diff
     1.1 --- a/tools/ioemu/hw/fdc.c	Mon Nov 27 10:08:12 2006 +0000
     1.2 +++ b/tools/ioemu/hw/fdc.c	Mon Nov 27 10:09:19 2006 +0000
     1.3 @@ -898,7 +898,7 @@ static void fdctrl_start_transfer (fdctr
     1.4          fdctrl->data_len = fdctrl->fifo[8];
     1.5      } else {
     1.6  	int tmp;
     1.7 -        fdctrl->data_len = 128 << fdctrl->fifo[5];
     1.8 +        fdctrl->data_len = 128 << (fdctrl->fifo[5] > 7 ? 7 : fdctrl->fifo[5]);
     1.9          tmp = (cur_drv->last_sect - ks + 1);
    1.10          if (fdctrl->fifo[0] & 0x80)
    1.11              tmp += cur_drv->last_sect;