aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2020-12-11 21:39:20 +0300
committerEric Blake <eblake@redhat.com>2021-02-03 08:00:33 -0600
commit4c002cef0e9abe7135d7916c51abce47f7fc1ee2 (patch)
treecd2bfc6b897f859e5c26f9c3b761c540a20f97cf /block
parent69b55e03f7e65a36eb954d0b7d4698b258df2708 (diff)
util/iov: make qemu_iovec_init_extended() honest
Actually, we can't extend the io vector in all cases. Handle possible MAX_IOV and size_t overflows. For now add assertion to callers (actually they rely on success anyway) and fix them in the following patch. Add also some additional good assertions to qemu_iovec_init_slice() while being here. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20201211183934.169161-3-vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/io.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/block/io.c b/block/io.c
index 23abdae794..ab953bd58f 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1680,13 +1680,17 @@ static bool bdrv_pad_request(BlockDriverState *bs,
int64_t *offset, unsigned int *bytes,
BdrvRequestPadding *pad)
{
+ int ret;
+
if (!bdrv_init_padding(bs, *offset, *bytes, pad)) {
return false;
}
- qemu_iovec_init_extended(&pad->local_qiov, pad->buf, pad->head,
- *qiov, *qiov_offset, *bytes,
- pad->buf + pad->buf_len - pad->tail, pad->tail);
+ ret = qemu_iovec_init_extended(&pad->local_qiov, pad->buf, pad->head,
+ *qiov, *qiov_offset, *bytes,
+ pad->buf + pad->buf_len - pad->tail,
+ pad->tail);
+ assert(ret == 0);
*bytes += pad->head + pad->tail;
*offset -= pad->head;
*qiov = &pad->local_qiov;