提交 cf49a6a0 编写于 作者: K Kevin Wolf 提交者: Stefan Hajnoczi

qemu-io: Handle cvtnum() errors in 'alloc'

Signed-off-by: NKevin Wolf <kwolf@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
上级 b6e356aa
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册