[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/17] qcow2: Fix alloc_clusters_noref() overflow det
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 01/17] qcow2: Fix alloc_clusters_noref() overflow detection |
Date: |
Fri, 9 May 2014 21:03:21 +0200 |
From: Max Reitz <address@hidden>
If the very first allocation has a length of 0, the free_cluster_index
is still 0 after the for loop, which means that subtracting one from it
will underflow and signal an invalid range of clusters by returning
-EFBIG. However, there is no such range, as its length is 0.
Fix this by preventing underflows on free_cluster_index during the
check.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block/qcow2-refcount.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index e79895d..9507aef 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -656,7 +656,9 @@ retry:
/* Make sure that all offsets in the "allocated" range are representable
* in an int64_t */
- if (s->free_cluster_index - 1 > (INT64_MAX >> s->cluster_bits)) {
+ if (s->free_cluster_index > 0 &&
+ s->free_cluster_index - 1 > (INT64_MAX >> s->cluster_bits))
+ {
return -EFBIG;
}
--
1.9.0
- [Qemu-devel] [PULL 00/17] Block patches, Stefan Hajnoczi, 2014/05/09
- [Qemu-devel] [PULL 02/17] iotests: Use configured python, Stefan Hajnoczi, 2014/05/09
- [Qemu-devel] [PULL 01/17] qcow2: Fix alloc_clusters_noref() overflow detection,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 03/17] qemu-img: sort block formats in help message, Stefan Hajnoczi, 2014/05/09
- Re: [Qemu-devel] [PULL 03/17] qemu-img: sort block formats in help message, Cornelia Huck, 2014/05/13
- Re: [Qemu-devel] [PULL 03/17] qemu-img: sort block formats in help message, Mike Day, 2014/05/13
- Re: [Qemu-devel] [PULL 03/17] qemu-img: sort block formats in help message, Stefan Hajnoczi, 2014/05/14
- Re: [Qemu-devel] [PULL 03/17] qemu-img: sort block formats in help message, Mike Day, 2014/05/14
- Re: [Qemu-devel] [PULL 03/17] qemu-img: sort block formats in help message, Fam Zheng, 2014/05/14
- Re: [Qemu-devel] [PULL 03/17] qemu-img: sort block formats in help message, Jeff Cody, 2014/05/14
- Re: [Qemu-devel] [PULL 03/17] qemu-img: sort block formats in help message, Jeff Cody, 2014/05/14
- Re: [Qemu-devel] [PULL 03/17] qemu-img: sort block formats in help message, Mike Day, 2014/05/14
[Qemu-devel] [PULL 04/17] block/nfs: Check for NULL server part, Stefan Hajnoczi, 2014/05/09