summaryrefslogtreecommitdiff
path: root/qemu-io.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2013-06-05 14:19:29 +0200
committerStefan Hajnoczi <stefanha@redhat.com>2013-06-06 11:27:03 +0200
commitcf49a6a00c19cabf4006d4f82bef26345043e7b5 (patch)
tree0d6828cb0c714c8068379bec5e33488cd986ec09 /qemu-io.c
parentb6e356aa25c81d928e1c463292048d29cf25f04e (diff)
downloadqemu-cf49a6a00c19cabf4006d4f82bef26345043e7b5.tar.gz
qemu-io: Handle cvtnum() errors in 'alloc'
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'qemu-io.c')
-rw-r--r--qemu-io.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/qemu-io.c b/qemu-io.c
index 8a719a881c..b4f56fc59f 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -1596,7 +1596,10 @@ static int alloc_f(int argc, char **argv)
int ret;
offset = cvtnum(argv[1]);
- if (offset & 0x1ff) {
+ if (offset < 0) {
+ printf("non-numeric offset argument -- %s\n", argv[1]);
+ return 0;
+ } else if (offset & 0x1ff) {
printf("offset %" PRId64 " is not sector aligned\n",
offset);
return 0;
@@ -1604,6 +1607,10 @@ static int alloc_f(int argc, char **argv)
if (argc == 3) {
nb_sectors = cvtnum(argv[2]);
+ if (nb_sectors < 0) {
+ printf("non-numeric length argument -- %s\n", argv[2]);
+ return 0;
+ }
} else {
nb_sectors = 1;
}