提交 86fa8da8 编写于 作者: K Kevin Wolf

qcow2: Fix corruption after error in update_refcount

After it is done with updating refcounts in the cache, update_refcount writes
all changed entries to disk. If a refcount block allocation fails, however,
there was no change yet and therefore first_index = last_index = -1. Don't
treat -1 as a normal sector index (resulting in a 512 byte write!) but return
without updating anything in this case.
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 25408c09
......@@ -417,6 +417,10 @@ static int write_refcount_block_entries(BlockDriverState *bs,
return 0;
}
if (first_index < 0) {
return 0;
}
first_index &= ~(REFCOUNTS_PER_SECTOR - 1);
last_index = (last_index + REFCOUNTS_PER_SECTOR)
& ~(REFCOUNTS_PER_SECTOR - 1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册