[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/14] qemu-img: Error out for excess arguments
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 01/14] qemu-img: Error out for excess arguments |
Date: |
Tue, 6 Aug 2013 16:39:37 +0200 |
Don't silently ignore excess arguments at the end of the command line,
but error out instead. This can catch typos like 'resize test.img + 1G',
which doesn't increase the image size by 1G as intended, but truncates
the image to 1G. Even for less dangerous commands, the old behaviour is
confusing.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Laszlo Ersek <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
qemu-img.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index c55ca5c..dece1b3 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -396,6 +396,9 @@ static int img_create(int argc, char **argv)
}
img_size = (uint64_t)sval;
}
+ if (optind != argc) {
+ help();
+ }
if (options && is_help_option(options)) {
return print_block_option_help(filename, fmt);
@@ -573,7 +576,7 @@ static int img_check(int argc, char **argv)
break;
}
}
- if (optind >= argc) {
+ if (optind != argc - 1) {
help();
}
filename = argv[optind++];
@@ -684,7 +687,7 @@ static int img_commit(int argc, char **argv)
break;
}
}
- if (optind >= argc) {
+ if (optind != argc - 1) {
help();
}
filename = argv[optind++];
@@ -930,7 +933,7 @@ static int img_compare(int argc, char **argv)
}
- if (optind > argc - 2) {
+ if (optind != argc - 2) {
help();
}
filename1 = argv[optind++];
@@ -1741,7 +1744,7 @@ static int img_info(int argc, char **argv)
break;
}
}
- if (optind >= argc) {
+ if (optind != argc - 1) {
help();
}
filename = argv[optind++];
@@ -1842,7 +1845,7 @@ static int img_snapshot(int argc, char **argv)
}
}
- if (optind >= argc) {
+ if (optind != argc - 1) {
help();
}
filename = argv[optind++];
@@ -1953,7 +1956,7 @@ static int img_rebase(int argc, char **argv)
progress = 0;
}
- if ((optind >= argc) || (!unsafe && !out_baseimg)) {
+ if ((optind != argc - 1) || (!unsafe && !out_baseimg)) {
help();
}
filename = argv[optind++];
@@ -2232,7 +2235,7 @@ static int img_resize(int argc, char **argv)
break;
}
}
- if (optind >= argc) {
+ if (optind != argc - 1) {
help();
}
filename = argv[optind++];
--
1.8.1.4
- [Qemu-devel] [PULL 00/14] Block fixes for 1.6, Kevin Wolf, 2013/08/06
- [Qemu-devel] [PULL 02/14] ignore SIGPIPE in qemu-img and qemu-io, Kevin Wolf, 2013/08/06
- [Qemu-devel] [PULL 03/14] iov: handle EOF in iov_send_recv, Kevin Wolf, 2013/08/06
- [Qemu-devel] [PULL 01/14] qemu-img: Error out for excess arguments,
Kevin Wolf <=
- [Qemu-devel] [PULL 05/14] sheepdog: add missing .bdrv_has_zero_init, Kevin Wolf, 2013/08/06
- [Qemu-devel] [PULL 04/14] qemu-iotests: filter QEMU version in monitor banner, Kevin Wolf, 2013/08/06
- [Qemu-devel] [PULL 09/14] qemu-iotests: add empty test case for vmdk, Kevin Wolf, 2013/08/06
- [Qemu-devel] [PULL 07/14] vmdk: use unsigned values for on disk header fields, Kevin Wolf, 2013/08/06
- [Qemu-devel] [PULL 08/14] qemu-iotests: add poke_file utility function, Kevin Wolf, 2013/08/06
- [Qemu-devel] [PULL 11/14] vmdk: check l2 table size when opening, Kevin Wolf, 2013/08/06
- [Qemu-devel] [PULL 12/14] vmdk: check l1 size before opening image, Kevin Wolf, 2013/08/06
- [Qemu-devel] [PULL 14/14] vmdk: rename num_gtes_per_gte to num_gtes_per_gt, Kevin Wolf, 2013/08/06
- [Qemu-devel] [PULL 13/14] vmdk: use heap allocation for whole_grain, Kevin Wolf, 2013/08/06
- [Qemu-devel] [PULL 10/14] vmdk: check granularity field in opening, Kevin Wolf, 2013/08/06