* [Qemu-devel] [PATCH v3] correct error message qemu-img reported
@ 2012-11-02 5:11 liguang
2012-11-02 7:16 ` Stefan Hajnoczi
0 siblings, 1 reply; 3+ messages in thread
From: liguang @ 2012-11-02 5:11 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, 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 | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index b41e670..d4ea800 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -337,10 +337,15 @@ static int img_create(int argc, char **argv)
/* Get image size, if specified */
if (optind < argc) {
- int64_t sval;
+ int64_t sval = 0;
char *end;
sval = strtosz_suffix(argv[optind++], &end, STRTOSZ_DEFSUFFIX_B);
- if (sval < 0 || *end) {
+ if (sval < 0) {
+ error_report("image size is too large!");
+ 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.");
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v3] correct error message qemu-img reported
2012-11-02 5:11 [Qemu-devel] [PATCH v3] correct error message qemu-img reported liguang
@ 2012-11-02 7:16 ` Stefan Hajnoczi
2012-11-05 7:40 ` li guang
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Hajnoczi @ 2012-11-02 7:16 UTC (permalink / raw)
To: liguang; +Cc: qemu-trivial, Kevin Wolf, qemu-devel
On Fri, Nov 2, 2012 at 6:11 AM, liguang <lig.fnst@cn.fujitsu.com> wrote:
> diff --git a/qemu-img.c b/qemu-img.c
> index b41e670..d4ea800 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -337,10 +337,15 @@ static int img_create(int argc, char **argv)
>
> /* Get image size, if specified */
> if (optind < argc) {
> - int64_t sval;
> + int64_t sval = 0;
sval is assigned below so there is no need for this change.
> char *end;
> sval = strtosz_suffix(argv[optind++], &end, STRTOSZ_DEFSUFFIX_B);
> - if (sval < 0 || *end) {
> + if (sval < 0) {
> + error_report("image size is too large!");
I suggest being specific about the upper limit so the user knows which
values are valid:
"Image size must be less than 8 exabytes!"
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v3] correct error message qemu-img reported
2012-11-02 7:16 ` Stefan Hajnoczi
@ 2012-11-05 7:40 ` li guang
0 siblings, 0 replies; 3+ messages in thread
From: li guang @ 2012-11-05 7:40 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: qemu-trivial, Kevin Wolf, qemu-devel
在 2012-11-02五的 08:16 +0100,Stefan Hajnoczi写道:
> On Fri, Nov 2, 2012 at 6:11 AM, liguang <lig.fnst@cn.fujitsu.com> wrote:
> > diff --git a/qemu-img.c b/qemu-img.c
> > index b41e670..d4ea800 100644
> > --- a/qemu-img.c
> > +++ b/qemu-img.c
> > @@ -337,10 +337,15 @@ static int img_create(int argc, char **argv)
> >
> > /* Get image size, if specified */
> > if (optind < argc) {
> > - int64_t sval;
> > + int64_t sval = 0;
>
> sval is assigned below so there is no need for this change.
>
> > char *end;
> > sval = strtosz_suffix(argv[optind++], &end, STRTOSZ_DEFSUFFIX_B);
> > - if (sval < 0 || *end) {
> > + if (sval < 0) {
> > + error_report("image size is too large!");
>
> I suggest being specific about the upper limit so the user knows which
> values are valid:
> "Image size must be less than 8 exabytes!"
>
> Stefan
>
OK, will fix.
--
liguang lig.fnst@cn.fujitsu.com
FNST linux kernel team
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-11-05 7:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-02 5:11 [Qemu-devel] [PATCH v3] correct error message qemu-img reported liguang
2012-11-02 7:16 ` Stefan Hajnoczi
2012-11-05 7:40 ` li guang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).