Patchwork [v4] correct error message qemu-img reported

login
register
mail settings
Submitter liguang
Date Nov. 5, 2012, 7:41 a.m.
Message ID <1352101300-12060-1-git-send-email-lig.fnst@cn.fujitsu.com>
Download mbox | patch
Permalink /patch/197157/
State New
Headers show

Comments

liguang - Nov. 5, 2012, 7:41 a.m.
qemu-img will complain when qcow or qcow2
size overflow for 64 bits, report the right
message in this condition.

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
 qemu-img.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
Stefan Hajnoczi - Nov. 5, 2012, 10:27 a.m.
On Mon, Nov 5, 2012 at 8:41 AM, liguang <lig.fnst@cn.fujitsu.com> wrote:
> qemu-img will complain when qcow or qcow2
> size overflow for 64 bits, report the right
> message in this condition.
>
> Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
> ---
>  qemu-img.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
liguang - Dec. 6, 2012, 8:47 a.m.
Hi, Stefan

seems this tiny patch was ignored.

在 2012-11-05一的 11:27 +0100,Stefan Hajnoczi写道:
> On Mon, Nov 5, 2012 at 8:41 AM, liguang <lig.fnst@cn.fujitsu.com> wrote:
> > qemu-img will complain when qcow or qcow2
> > size overflow for 64 bits, report the right
> > message in this condition.
> >
> > Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
> > ---
> >  qemu-img.c |    7 ++++++-
> >  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Kevin Wolf - Dec. 6, 2012, 10:04 a.m.
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 <lig.fnst@cn.fujitsu.com>
> ---
>  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.");
>
liguang - Dec. 7, 2012, 3:56 a.m.
在 2012-12-06四的 11:04 +0100,Kevin Wolf写道:
> 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 <lig.fnst@cn.fujitsu.com>
> > ---
> >  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!
> 

Oh, my fault, I'll fix.
Thanks!

> 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.");
> > 
> 
> 
>
Anthony Liguori - Jan. 3, 2013, 12:19 a.m.
Hi,

This is an automated message generated from the QEMU Patches.
Thank you for submitting this patch.  This patch no longer applies to qemu.git.

This may have occurred due to:
 
  1) Changes in mainline requiring your patch to be rebased and re-tested.

  2) Sending the mail using a tool other than git-send-email.  Please use
     git-send-email to send patches to QEMU.

  3) Basing this patch off of a branch that isn't tracking the QEMU
     master branch.  If that was done purposefully, please include the name
     of the tree in the subject line in the future to prevent this message.

     For instance: "[PATCH block-next 1/10] qcow3: add fancy new feature"

  4) You no longer wish for this patch to be applied to QEMU.  No additional
     action is required on your part.

Nacked-by: QEMU Patches <aliguori@us.ibm.com>

Below is the output from git-am:

    Applying: correct error message qemu-img reported
    Using index info to reconstruct a base tree...
    M	qemu-img.c
    Falling back to patching base and 3-way merge...
    Auto-merging qemu-img.c
    CONFLICT (content): Merge conflict in qemu-img.c
    Failed to merge in the changes.
    Patch failed at 0001 correct error message qemu-img reported
    The copy of the patch that failed is found in:
       /home/aliguori/patches/qemu.git/.git/rebase-apply/patch
    When you have resolved this problem run "git am --resolved".
    If you would prefer to skip this patch, instead run "git am --skip".
    To restore the original branch and stop patching run "git am --abort".
Peter Maydell - Jan. 3, 2013, 1:08 a.m.
On 3 January 2013 00:19, Anthony Liguori <aliguori@us.ibm.com> wrote:
> This is an automated message generated from the QEMU Patches.
> Thank you for submitting this patch.  This patch no longer applies to qemu.git.

> Nacked-by: QEMU Patches <aliguori@us.ibm.com>

Are we going to get these emails on every old patch that was
superseded by a later fixed version 2?

-- PMM
Anthony Liguori - Jan. 3, 2013, 2:15 a.m.
Peter Maydell <peter.maydell@linaro.org> writes:

> On 3 January 2013 00:19, Anthony Liguori <aliguori@us.ibm.com> wrote:
>> This is an automated message generated from the QEMU Patches.
>> Thank you for submitting this patch.  This patch no longer applies to qemu.git.
>
>> Nacked-by: QEMU Patches <aliguori@us.ibm.com>
>
> Are we going to get these emails on every old patch that was
> superseded by a later fixed version 2?

Nope.

Patches detects obsoleted patches and ignores them.  It also detects
patches that have been committed in submaintainer trees but have not yet
made there way into qemu.git.

Regards,

Anthony Liguori

>
> -- PMM

Patch

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;
+        }
+        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.");