[Sheepdog] [PATCH 1/5] collie vdi read: do not try to read beyond end of vdi
Chris Webb
chris at arachsys.com
Sat Aug 13 12:56:18 CEST 2011
Signed-off-by: Chris Webb <chris at arachsys.com>
---
collie/vdi.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/collie/vdi.c b/collie/vdi.c
index 070539c..e6c32fc 100644
--- a/collie/vdi.c
+++ b/collie/vdi.c
@@ -1012,8 +1012,15 @@ static int vdi_read(int argc, char **argv)
goto out;
}
+ if (inode->vdi_size < offset) {
+ fprintf(stderr, "offset beyond end of vdi\n");
+ ret = EXIT_FAILURE;
+ goto out;
+ }
+
+ total = min(total, inode->vdi_size - offset);
idx = offset / SD_DATA_OBJ_SIZE;
- while (done != total) {
+ while (done < total) {
len = min(total - done, SD_DATA_OBJ_SIZE - offset);
if (inode->data_vdi_id[idx]) {
--
1.7.5.4
More information about the sheepdog
mailing list