* [Qemu-devel] [PATCH] Improve block range checks
@ 2009-05-08 12:47 Kevin Wolf
0 siblings, 0 replies; only message in thread
From: Kevin Wolf @ 2009-05-08 12:47 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf
This patch makes the range checks for block requests more strict: It fixes a
potential integer overflow and checks for negative offsets. Also, it adds the
check for compressed writes.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/block.c b/block.c
index 3d1223d..acb8976 100644
--- a/block.c
+++ b/block.c
@@ -578,7 +578,10 @@ static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset,
len = bdrv_getlength(bs);
- if ((offset + size) > len)
+ if (offset < 0)
+ return -EIO;
+
+ if ((offset > len) || (len - offset < size))
return -EIO;
return 0;
@@ -1150,6 +1153,8 @@ int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
return -ENOMEDIUM;
if (!drv->bdrv_write_compressed)
return -ENOTSUP;
+ if (bdrv_check_request(bs, sector_num, nb_sectors))
+ return -EIO;
return drv->bdrv_write_compressed(bs, sector_num, buf, nb_sectors);
}
--
1.6.0.6
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2009-05-08 12:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-08 12:47 [Qemu-devel] [PATCH] Improve block range checks Kevin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).