|
|
218e99 |
From 00e5b1ffe79264929ea0dab871e5e797ab85497f Mon Sep 17 00:00:00 2001
|
|
|
218e99 |
From: Max Reitz <mreitz@redhat.com>
|
|
|
218e99 |
Date: Mon, 19 Aug 2013 11:09:45 +0200
|
|
|
218e99 |
Subject: qemu-img: Error out for excess arguments
|
|
|
218e99 |
|
|
|
218e99 |
RH-Author: Max Reitz <mreitz@redhat.com>
|
|
|
218e99 |
Message-id: <1376910585-8875-1-git-send-email-mreitz@redhat.com>
|
|
|
218e99 |
Patchwork-id: 53597
|
|
|
218e99 |
O-Subject: [RHEL-7 qemu-kvm PATCH] qemu-img: Error out for excess arguments
|
|
|
218e99 |
Bugzilla: 992935
|
|
|
218e99 |
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
218e99 |
|
|
|
218e99 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
218e99 |
|
|
|
218e99 |
Don't silently ignore excess arguments at the end of the command line,
|
|
|
218e99 |
but error out instead. This can catch typos like 'resize test.img + 1G',
|
|
|
218e99 |
which doesn't increase the image size by 1G as intended, but truncates
|
|
|
218e99 |
the image to 1G. Even for less dangerous commands, the old behaviour is
|
|
|
218e99 |
confusing.
|
|
|
218e99 |
|
|
|
218e99 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
218e99 |
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
218e99 |
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
218e99 |
(cherry picked from commit fc11eb26cee7e3621645dd40cd9de944201f590b)
|
|
|
218e99 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
218e99 |
|
|
|
218e99 |
BZ: https:
|
|
|
218e99 |
Brew: https:
|
|
|
218e99 |
|
|
|
218e99 |
diff
|
|
|
218e99 |
index cd096a1..c20ff66 100644
|
|
|
218e99 |
|
|
|
218e99 |
|
|
|
218e99 |
@@ -393,6 +393,9 @@ static int img_create(int argc, char **argv)
|
|
|
218e99 |
}
|
|
|
218e99 |
img_size = (uint64_t)sval;
|
|
|
218e99 |
}
|
|
|
218e99 |
+ if (optind != argc) {
|
|
|
218e99 |
+ help();
|
|
|
218e99 |
+ }
|
|
|
218e99 |
|
|
|
218e99 |
if (options && is_help_option(options)) {
|
|
|
218e99 |
return print_block_option_help(filename, fmt);
|
|
|
218e99 |
@@ -570,7 +573,7 @@ static int img_check(int argc, char **argv)
|
|
|
218e99 |
break;
|
|
|
218e99 |
}
|
|
|
218e99 |
}
|
|
|
218e99 |
- if (optind >= argc) {
|
|
|
218e99 |
+ if (optind != argc - 1) {
|
|
|
218e99 |
help();
|
|
|
218e99 |
}
|
|
|
218e99 |
filename = argv[optind++];
|
|
|
218e99 |
@@ -681,7 +684,7 @@ static int img_commit(int argc, char **argv)
|
|
|
218e99 |
break;
|
|
|
218e99 |
}
|
|
|
218e99 |
}
|
|
|
218e99 |
- if (optind >= argc) {
|
|
|
218e99 |
+ if (optind != argc - 1) {
|
|
|
218e99 |
help();
|
|
|
218e99 |
}
|
|
|
218e99 |
filename = argv[optind++];
|
|
|
218e99 |
@@ -927,7 +930,7 @@ static int img_compare(int argc, char **argv)
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
|
|
|
218e99 |
- if (optind > argc - 2) {
|
|
|
218e99 |
+ if (optind != argc - 2) {
|
|
|
218e99 |
help();
|
|
|
218e99 |
}
|
|
|
218e99 |
filename1 = argv[optind++];
|
|
|
218e99 |
@@ -1882,7 +1885,7 @@ static int img_info(int argc, char **argv)
|
|
|
218e99 |
break;
|
|
|
218e99 |
}
|
|
|
218e99 |
}
|
|
|
218e99 |
- if (optind >= argc) {
|
|
|
218e99 |
+ if (optind != argc - 1) {
|
|
|
218e99 |
help();
|
|
|
218e99 |
}
|
|
|
218e99 |
filename = argv[optind++];
|
|
|
218e99 |
@@ -1983,7 +1986,7 @@ static int img_snapshot(int argc, char **argv)
|
|
|
218e99 |
}
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
- if (optind >= argc) {
|
|
|
218e99 |
+ if (optind != argc - 1) {
|
|
|
218e99 |
help();
|
|
|
218e99 |
}
|
|
|
218e99 |
filename = argv[optind++];
|
|
|
218e99 |
@@ -2094,7 +2097,7 @@ static int img_rebase(int argc, char **argv)
|
|
|
218e99 |
progress = 0;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
- if ((optind >= argc) || (!unsafe && !out_baseimg)) {
|
|
|
218e99 |
+ if ((optind != argc - 1) || (!unsafe && !out_baseimg)) {
|
|
|
218e99 |
help();
|
|
|
218e99 |
}
|
|
|
218e99 |
filename = argv[optind++];
|
|
|
218e99 |
@@ -2373,7 +2376,7 @@ static int img_resize(int argc, char **argv)
|
|
|
218e99 |
break;
|
|
|
218e99 |
}
|
|
|
218e99 |
}
|
|
|
218e99 |
- if (optind >= argc) {
|
|
|
218e99 |
+ if (optind != argc - 1) {
|
|
|
218e99 |
help();
|
|
|
218e99 |
}
|
|
|
218e99 |
filename = argv[optind++];
|