qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v4] correct error message qemu-img reported


From: Kevin Wolf
Subject: Re: [Qemu-devel] [PATCH v4] correct error message qemu-img reported
Date: Thu, 06 Dec 2012 11:04:08 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0

Am 05.11.2012 08:41, schrieb liguang:
> qemu-img will complain when qcow or qcow2
> size overflow for 64 bits, report the right
> message in this condition.
> 
> Signed-off-by: liguang <address@hidden>
> ---
>  qemu-img.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/qemu-img.c b/qemu-img.c
> index b41e670..d9434ad 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -340,7 +340,12 @@ static int img_create(int argc, char **argv)
>          int64_t sval;
>          char *end;
>          sval = strtosz_suffix(argv[optind++], &end, STRTOSZ_DEFSUFFIX_B);
> -        if (sval < 0 || *end) {
> +        if (sval < 0) {
> +            error_report("Image size must be less than 8 exabytes!");
> +            ret = -1;
> +            goto out;
> +        }

This is wrong, overflows are not the only way how strtosz_suffix() can fail.

Before this patch:

$ ./qemu-img create /tmp/foo bar
qemu-img: Invalid image size specified! You may use k, M, G or T
suffixes for
qemu-img: kilobytes, megabytes, gigabytes and terabytes

With the patch applied:

$ ./qemu-img create /tmp/foo bar
qemu-img: Image size must be less than 8 exabytes!

Kevin


> +        if (*end) {
>              error_report("Invalid image size specified! You may use k, M, G 
> or "
>                    "T suffixes for ");
>              error_report("kilobytes, megabytes, gigabytes and terabytes.");
> 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]