[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH v1 04/15] qcow: require image size to be > 1 for
From: |
Max Reitz |
Subject: |
Re: [Qemu-block] [PATCH v1 04/15] qcow: require image size to be > 1 for new images |
Date: |
Mon, 16 Jan 2017 20:41:15 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 |
On 03.01.2017 19:27, Daniel P. Berrange wrote:
> The qcow driver refuses to open images which are less than
> 2 bytes in size, but will happily create such images. Add
> a check in the create path to avoid this discrepancy.
>
> Signed-off-by: Daniel P. Berrange <address@hidden>
> ---
> block/qcow.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/block/qcow.c b/block/qcow.c
> index 7540f43..8133fda 100644
> --- a/block/qcow.c
> +++ b/block/qcow.c
> @@ -799,6 +799,12 @@ static int qcow_create(const char *filename, QemuOpts
> *opts, Error **errp)
> /* Read out options */
> total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
> BDRV_SECTOR_SIZE);
> + if (total_size <= 1) {
> + error_setg(errp, "Image size is too small (must be at least 2
> bytes)");
> + ret = -EINVAL;
> + goto cleanup;
> + }
> +
Given the ROUND_UP() before, I can't see how total_size can be 1, but I
can see how it can be 0. Since that is covered by this condition:
Reviewed-by: Max Reitz <address@hidden>
> backing_file = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FILE);
> if (qemu_opt_get_bool_del(opts, BLOCK_OPT_ENCRYPT, false)) {
> flags |= BLOCK_FLAG_ENCRYPT;
>
signature.asc
Description: OpenPGP digital signature
- [Qemu-block] [PATCH v1 01/15] block: expose crypto option names / defs to other drivers, (continued)
- [Qemu-block] [PATCH v1 01/15] block: expose crypto option names / defs to other drivers, Daniel P. Berrange, 2017/01/03
- [Qemu-block] [PATCH v1 02/15] block: add ability to set a prefix for opt names, Daniel P. Berrange, 2017/01/03
- [Qemu-block] [PATCH v1 03/15] qcow: document another weakness of qcow AES encryption, Daniel P. Berrange, 2017/01/03
- [Qemu-block] [PATCH v1 04/15] qcow: require image size to be > 1 for new images, Daniel P. Berrange, 2017/01/03
- Re: [Qemu-block] [PATCH v1 04/15] qcow: require image size to be > 1 for new images,
Max Reitz <=
- [Qemu-block] [PATCH v1 05/15] iotests: skip 042 with qcow which dosn't support zero sized images, Daniel P. Berrange, 2017/01/03
- [Qemu-block] [PATCH v1 06/15] iotests: skip 048 with qcow which doesn't support resize, Daniel P. Berrange, 2017/01/03
- [Qemu-block] [PATCH v1 08/15] qcow: make encrypt_sectors encrypt in place, Daniel P. Berrange, 2017/01/03
- [Qemu-block] [PATCH v1 07/15] iotests: fix 097 when run with qcow, Daniel P. Berrange, 2017/01/03