ia64/xen-unstable

changeset 14913:837d12d4d2d1

[qemu-dm] Add bounds checks to block device reads/writes.

Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
author Christian Limpach <Christian.Limpach@xensource.com>
date Tue Apr 24 17:02:09 2007 +0100 (2007-04-24)
parents 9e86260b95a4
children c1d3f4fbfacf
files tools/ioemu/block.c
line diff
     1.1 --- a/tools/ioemu/block.c	Tue Apr 24 17:02:07 2007 +0100
     1.2 +++ b/tools/ioemu/block.c	Tue Apr 24 17:02:09 2007 +0100
     1.3 @@ -420,6 +420,8 @@ int bdrv_read(BlockDriverState *bs, int6
     1.4  
     1.5      if (!bs->inserted)
     1.6          return -1;
     1.7 +    if (sector_num < 0)
     1.8 +	return -1;
     1.9  
    1.10      while (nb_sectors > 0) {
    1.11          if (sector_num == 0 && bs->boot_sector_enabled) {
    1.12 @@ -458,6 +460,8 @@ int bdrv_write(BlockDriverState *bs, int
    1.13          return -1;
    1.14      if (bs->read_only)
    1.15          return -1;
    1.16 +    if (sector_num < 0)
    1.17 +	return -1;
    1.18      if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) {
    1.19          memcpy(bs->boot_sector_data, buf, 512);   
    1.20      }