correct error message qemu-img reported
PATCH v3 1/1 correct error message qemu-img reported
qemu-img will complain when qcow or qcow2
size overflow for 64 bits, report the right
message in this condition.
--- qemu-img.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
qemu-img.c +7 -2
@@ -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." );
Signature · 1 line
1.7.1
qemu-img.c static int img_create(int argc, char **argv) · line 340
Quoted 10 lines · liguang
qemu-img.c +1
-1@@ -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.
qemu-img.c static int img_create(int argc, char **argv) · line 344
Quoted 5 lines
qemu-img.c +2
-1char *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
Quoted 20 lines · 在 2012-11-02五的 08:16 +0100,Stefan Hajnoczi写道:
qemu-img.c static int img_create(int argc, char **argv) · line 340
Quoted 10 lines · liguang
qemu-img.c +1
-1@@ -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.
qemu-img.c static int img_create(int argc, char **argv) · line 344
Quoted 5 lines
qemu-img.c +2
-1char *end; sval =strtosz_suffix (argv[optind++], &end,STRTOSZ_DEFSUFFIX_B ); -if (sval <0 || *end) { +if (sval <0 ) { +error_report ("image size is too large!" );
Quoted 6 lines
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.
Signature · 2 lines
liguang [email protected] FNST linux kernel team