|
|
9ae3a8 |
From a5226789eaaedf06f50f2faf14b506c17deb5435 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
Date: Mon, 23 Nov 2015 17:38:37 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 18/27] qemu-io: fix cvtnum lval types
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1448300320-7772-19-git-send-email-jsnow@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 68445
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.3 qemu-kvm PATCH v2 18/21] qemu-io: fix cvtnum lval types
|
|
|
9ae3a8 |
Bugzilla: 1272523
|
|
|
9ae3a8 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
cvtnum() returns int64_t: we should not be storing this
|
|
|
9ae3a8 |
result inside of an int.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
In a few cases, we need an extra sprinkling of error handling
|
|
|
9ae3a8 |
where we expect to pass this number on towards a function that
|
|
|
9ae3a8 |
expects something smaller than int64_t.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Reported-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 9b0beaf3de1396a23d5c287283e6f36c4b5d4385)
|
|
|
9ae3a8 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts:
|
|
|
9ae3a8 |
qemu-io-cmds.c:
|
|
|
9ae3a8 |
- Upstream uses blk_xxx commands, while downstream uses bdrv_xxx
|
|
|
9ae3a8 |
- Fixes to sigraise are not backported.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
qemu-io-cmds.c | 119 ++++++++++++++++++++++++++++++++++++++++-----------------
|
|
|
9ae3a8 |
1 file changed, 84 insertions(+), 35 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
|
|
|
9ae3a8 |
index 1f21ce9..95345fe 100644
|
|
|
9ae3a8 |
--- a/qemu-io-cmds.c
|
|
|
9ae3a8 |
+++ b/qemu-io-cmds.c
|
|
|
9ae3a8 |
@@ -282,9 +282,10 @@ static void qemu_io_free(void *p)
|
|
|
9ae3a8 |
qemu_vfree(p);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-static void dump_buffer(const void *buffer, int64_t offset, int len)
|
|
|
9ae3a8 |
+static void dump_buffer(const void *buffer, int64_t offset, int64_t len)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- int i, j;
|
|
|
9ae3a8 |
+ uint64_t i;
|
|
|
9ae3a8 |
+ int j;
|
|
|
9ae3a8 |
const uint8_t *p;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
for (i = 0, p = buffer; i < len; i += 16) {
|
|
|
9ae3a8 |
@@ -307,7 +308,7 @@ static void dump_buffer(const void *buffer, int64_t offset, int len)
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static void print_report(const char *op, struct timeval *t, int64_t offset,
|
|
|
9ae3a8 |
- int count, int total, int cnt, int Cflag)
|
|
|
9ae3a8 |
+ int64_t count, int64_t total, int cnt, int Cflag)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
char s1[64], s2[64], ts[64];
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -315,12 +316,12 @@ static void print_report(const char *op, struct timeval *t, int64_t offset,
|
|
|
9ae3a8 |
if (!Cflag) {
|
|
|
9ae3a8 |
cvtstr((double)total, s1, sizeof(s1));
|
|
|
9ae3a8 |
cvtstr(tdiv((double)total, *t), s2, sizeof(s2));
|
|
|
9ae3a8 |
- printf("%s %d/%d bytes at offset %" PRId64 "\n",
|
|
|
9ae3a8 |
+ printf("%s %"PRId64"/%"PRId64" bytes at offset %" PRId64 "\n",
|
|
|
9ae3a8 |
op, total, count, offset);
|
|
|
9ae3a8 |
printf("%s, %d ops; %s (%s/sec and %.4f ops/sec)\n",
|
|
|
9ae3a8 |
s1, cnt, ts, s2, tdiv((double)cnt, *t));
|
|
|
9ae3a8 |
} else {/* bytes,ops,time,bytes/sec,ops/sec */
|
|
|
9ae3a8 |
- printf("%d,%d,%s,%.3f,%.3f\n",
|
|
|
9ae3a8 |
+ printf("%"PRId64",%d,%s,%.3f,%.3f\n",
|
|
|
9ae3a8 |
total, cnt, ts,
|
|
|
9ae3a8 |
tdiv((double)total, *t),
|
|
|
9ae3a8 |
tdiv((double)cnt, *t));
|
|
|
9ae3a8 |
@@ -381,11 +382,15 @@ fail:
|
|
|
9ae3a8 |
return buf;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-static int do_read(BlockDriverState *bs, char *buf, int64_t offset, int count,
|
|
|
9ae3a8 |
- int *total)
|
|
|
9ae3a8 |
+static int do_read(BlockDriverState *bs, char *buf, int64_t offset,
|
|
|
9ae3a8 |
+ int64_t count, int64_t *total)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
int ret;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ if (count >> 9 > INT_MAX) {
|
|
|
9ae3a8 |
+ return -ERANGE;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
ret = bdrv_read(bs, offset >> 9, (uint8_t *)buf, count >> 9);
|
|
|
9ae3a8 |
if (ret < 0) {
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
@@ -394,11 +399,15 @@ static int do_read(BlockDriverState *bs, char *buf, int64_t offset, int count,
|
|
|
9ae3a8 |
return 1;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-static int do_write(BlockDriverState *bs, char *buf, int64_t offset, int count,
|
|
|
9ae3a8 |
- int *total)
|
|
|
9ae3a8 |
+static int do_write(BlockDriverState *bs, char *buf, int64_t offset,
|
|
|
9ae3a8 |
+ int64_t count, int64_t *total)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
int ret;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ if (count >> 9 > INT_MAX) {
|
|
|
9ae3a8 |
+ return -ERANGE;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
ret = bdrv_write(bs, offset >> 9, (uint8_t *)buf, count >> 9);
|
|
|
9ae3a8 |
if (ret < 0) {
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
@@ -407,9 +416,13 @@ static int do_write(BlockDriverState *bs, char *buf, int64_t offset, int count,
|
|
|
9ae3a8 |
return 1;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-static int do_pread(BlockDriverState *bs, char *buf, int64_t offset, int count,
|
|
|
9ae3a8 |
- int *total)
|
|
|
9ae3a8 |
+static int do_pread(BlockDriverState *bs, char *buf, int64_t offset,
|
|
|
9ae3a8 |
+ int64_t count, int64_t *total)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
+ if (count > INT_MAX) {
|
|
|
9ae3a8 |
+ return -ERANGE;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
*total = bdrv_pread(bs, offset, (uint8_t *)buf, count);
|
|
|
9ae3a8 |
if (*total < 0) {
|
|
|
9ae3a8 |
return *total;
|
|
|
9ae3a8 |
@@ -417,9 +430,13 @@ static int do_pread(BlockDriverState *bs, char *buf, int64_t offset, int count,
|
|
|
9ae3a8 |
return 1;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-static int do_pwrite(BlockDriverState *bs, char *buf, int64_t offset, int count,
|
|
|
9ae3a8 |
- int *total)
|
|
|
9ae3a8 |
+static int do_pwrite(BlockDriverState *bs, char *buf, int64_t offset,
|
|
|
9ae3a8 |
+ int64_t count, int64_t *total)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
+ if (count > INT_MAX) {
|
|
|
9ae3a8 |
+ return -ERANGE;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
*total = bdrv_pwrite(bs, offset, (uint8_t *)buf, count);
|
|
|
9ae3a8 |
if (*total < 0) {
|
|
|
9ae3a8 |
return *total;
|
|
|
9ae3a8 |
@@ -430,8 +447,8 @@ static int do_pwrite(BlockDriverState *bs, char *buf, int64_t offset, int count,
|
|
|
9ae3a8 |
typedef struct {
|
|
|
9ae3a8 |
BlockDriverState *bs;
|
|
|
9ae3a8 |
int64_t offset;
|
|
|
9ae3a8 |
- int count;
|
|
|
9ae3a8 |
- int *total;
|
|
|
9ae3a8 |
+ int64_t count;
|
|
|
9ae3a8 |
+ int64_t *total;
|
|
|
9ae3a8 |
int ret;
|
|
|
9ae3a8 |
bool done;
|
|
|
9ae3a8 |
} CoWriteZeroes;
|
|
|
9ae3a8 |
@@ -451,8 +468,8 @@ static void coroutine_fn co_write_zeroes_entry(void *opaque)
|
|
|
9ae3a8 |
*data->total = data->count;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-static int do_co_write_zeroes(BlockDriverState *bs, int64_t offset, int count,
|
|
|
9ae3a8 |
- int *total)
|
|
|
9ae3a8 |
+static int do_co_write_zeroes(BlockDriverState *bs, int64_t offset,
|
|
|
9ae3a8 |
+ int64_t count, int64_t *total)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
Coroutine *co;
|
|
|
9ae3a8 |
CoWriteZeroes data = {
|
|
|
9ae3a8 |
@@ -463,6 +480,10 @@ static int do_co_write_zeroes(BlockDriverState *bs, int64_t offset, int count,
|
|
|
9ae3a8 |
.done = false,
|
|
|
9ae3a8 |
};
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ if (count >> BDRV_SECTOR_BITS > INT_MAX) {
|
|
|
9ae3a8 |
+ return -ERANGE;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
co = qemu_coroutine_create(co_write_zeroes_entry);
|
|
|
9ae3a8 |
qemu_coroutine_enter(co, &data);
|
|
|
9ae3a8 |
while (!data.done) {
|
|
|
9ae3a8 |
@@ -476,10 +497,14 @@ static int do_co_write_zeroes(BlockDriverState *bs, int64_t offset, int count,
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static int do_write_compressed(BlockDriverState *bs, char *buf, int64_t offset,
|
|
|
9ae3a8 |
- int count, int *total)
|
|
|
9ae3a8 |
+ int64_t count, int64_t *total)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
int ret;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ if (count >> 9 > INT_MAX) {
|
|
|
9ae3a8 |
+ return -ERANGE;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
ret = bdrv_write_compressed(bs, offset >> 9, (uint8_t *)buf, count >> 9);
|
|
|
9ae3a8 |
if (ret < 0) {
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
@@ -489,8 +514,12 @@ static int do_write_compressed(BlockDriverState *bs, char *buf, int64_t offset,
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static int do_load_vmstate(BlockDriverState *bs, char *buf, int64_t offset,
|
|
|
9ae3a8 |
- int count, int *total)
|
|
|
9ae3a8 |
+ int64_t count, int64_t *total)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
+ if (count > INT_MAX) {
|
|
|
9ae3a8 |
+ return -ERANGE;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
*total = bdrv_load_vmstate(bs, (uint8_t *)buf, offset, count);
|
|
|
9ae3a8 |
if (*total < 0) {
|
|
|
9ae3a8 |
return *total;
|
|
|
9ae3a8 |
@@ -499,8 +528,12 @@ static int do_load_vmstate(BlockDriverState *bs, char *buf, int64_t offset,
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static int do_save_vmstate(BlockDriverState *bs, char *buf, int64_t offset,
|
|
|
9ae3a8 |
- int count, int *total)
|
|
|
9ae3a8 |
+ int64_t count, int64_t *total)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
+ if (count > INT_MAX) {
|
|
|
9ae3a8 |
+ return -ERANGE;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
*total = bdrv_save_vmstate(bs, (uint8_t *)buf, offset, count);
|
|
|
9ae3a8 |
if (*total < 0) {
|
|
|
9ae3a8 |
return *total;
|
|
|
9ae3a8 |
@@ -630,10 +663,11 @@ static int read_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
int c, cnt;
|
|
|
9ae3a8 |
char *buf;
|
|
|
9ae3a8 |
int64_t offset;
|
|
|
9ae3a8 |
- int count;
|
|
|
9ae3a8 |
+ int64_t count;
|
|
|
9ae3a8 |
/* Some compilers get confused and warn if this is not initialized. */
|
|
|
9ae3a8 |
- int total = 0;
|
|
|
9ae3a8 |
- int pattern = 0, pattern_offset = 0, pattern_count = 0;
|
|
|
9ae3a8 |
+ int64_t total = 0;
|
|
|
9ae3a8 |
+ int pattern = 0;
|
|
|
9ae3a8 |
+ int64_t pattern_offset = 0, pattern_count = 0;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
while ((c = getopt(argc, argv, "bCl:pP:qs:v")) != EOF) {
|
|
|
9ae3a8 |
switch (c) {
|
|
|
9ae3a8 |
@@ -700,6 +734,10 @@ static int read_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
if (count < 0) {
|
|
|
9ae3a8 |
printf("non-numeric length argument -- %s\n", argv[optind]);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
+ } else if (count > SIZE_MAX) {
|
|
|
9ae3a8 |
+ printf("length cannot exceed %" PRIu64 ", given %s\n",
|
|
|
9ae3a8 |
+ (uint64_t) SIZE_MAX, argv[optind]);
|
|
|
9ae3a8 |
+ return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (!Pflag && (lflag || sflag)) {
|
|
|
9ae3a8 |
@@ -722,7 +760,7 @@ static int read_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
if (count & 0x1ff) {
|
|
|
9ae3a8 |
- printf("count %d is not sector aligned\n",
|
|
|
9ae3a8 |
+ printf("count %"PRId64" is not sector aligned\n",
|
|
|
9ae3a8 |
count);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -750,7 +788,7 @@ static int read_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
memset(cmp_buf, pattern, pattern_count);
|
|
|
9ae3a8 |
if (memcmp(buf + pattern_offset, cmp_buf, pattern_count)) {
|
|
|
9ae3a8 |
printf("Pattern verification failed at offset %"
|
|
|
9ae3a8 |
- PRId64 ", %d bytes\n",
|
|
|
9ae3a8 |
+ PRId64 ", %"PRId64" bytes\n",
|
|
|
9ae3a8 |
offset + pattern_offset, pattern_count);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
g_free(cmp_buf);
|
|
|
9ae3a8 |
@@ -945,9 +983,9 @@ static int write_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
int c, cnt;
|
|
|
9ae3a8 |
char *buf = NULL;
|
|
|
9ae3a8 |
int64_t offset;
|
|
|
9ae3a8 |
- int count;
|
|
|
9ae3a8 |
+ int64_t count;
|
|
|
9ae3a8 |
/* Some compilers get confused and warn if this is not initialized. */
|
|
|
9ae3a8 |
- int total = 0;
|
|
|
9ae3a8 |
+ int64_t total = 0;
|
|
|
9ae3a8 |
int pattern = 0xcd;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
while ((c = getopt(argc, argv, "bcCpP:qz")) != EOF) {
|
|
|
9ae3a8 |
@@ -1007,6 +1045,10 @@ static int write_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
if (count < 0) {
|
|
|
9ae3a8 |
printf("non-numeric length argument -- %s\n", argv[optind]);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
+ } else if (count > SIZE_MAX) {
|
|
|
9ae3a8 |
+ printf("length cannot exceed %" PRIu64 ", given %s\n",
|
|
|
9ae3a8 |
+ (uint64_t) SIZE_MAX, argv[optind]);
|
|
|
9ae3a8 |
+ return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (!pflag) {
|
|
|
9ae3a8 |
@@ -1017,7 +1059,7 @@ static int write_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (count & 0x1ff) {
|
|
|
9ae3a8 |
- printf("count %d is not sector aligned\n",
|
|
|
9ae3a8 |
+ printf("count %"PRId64" is not sector aligned\n",
|
|
|
9ae3a8 |
count);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -1752,8 +1794,7 @@ static int discard_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
struct timeval t1, t2;
|
|
|
9ae3a8 |
int Cflag = 0, qflag = 0;
|
|
|
9ae3a8 |
int c, ret;
|
|
|
9ae3a8 |
- int64_t offset;
|
|
|
9ae3a8 |
- int count;
|
|
|
9ae3a8 |
+ int64_t offset, count;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
while ((c = getopt(argc, argv, "Cq")) != EOF) {
|
|
|
9ae3a8 |
switch (c) {
|
|
|
9ae3a8 |
@@ -1783,6 +1824,11 @@ static int discard_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
if (count < 0) {
|
|
|
9ae3a8 |
printf("non-numeric length argument -- %s\n", argv[optind]);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
+ } else if (count >> BDRV_SECTOR_BITS > INT_MAX) {
|
|
|
9ae3a8 |
+ printf("length cannot exceed %"PRIu64", given %s\n",
|
|
|
9ae3a8 |
+ (uint64_t)INT_MAX << BDRV_SECTOR_BITS,
|
|
|
9ae3a8 |
+ argv[optind]);
|
|
|
9ae3a8 |
+ return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
gettimeofday(&t1, NULL);
|
|
|
9ae3a8 |
@@ -1807,11 +1853,10 @@ out:
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static int alloc_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- int64_t offset, sector_num;
|
|
|
9ae3a8 |
- int nb_sectors, remaining;
|
|
|
9ae3a8 |
+ int64_t offset, sector_num, nb_sectors, remaining;
|
|
|
9ae3a8 |
char s1[64];
|
|
|
9ae3a8 |
- int num, sum_alloc;
|
|
|
9ae3a8 |
- int ret;
|
|
|
9ae3a8 |
+ int num, ret;
|
|
|
9ae3a8 |
+ int64_t sum_alloc;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
offset = cvtnum(argv[1]);
|
|
|
9ae3a8 |
if (offset < 0) {
|
|
|
9ae3a8 |
@@ -1828,6 +1873,10 @@ static int alloc_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
if (nb_sectors < 0) {
|
|
|
9ae3a8 |
printf("non-numeric length argument -- %s\n", argv[2]);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
+ } else if (nb_sectors > INT_MAX) {
|
|
|
9ae3a8 |
+ printf("length argument cannot exceed %d, given %s\n",
|
|
|
9ae3a8 |
+ INT_MAX, argv[2]);
|
|
|
9ae3a8 |
+ return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
} else {
|
|
|
9ae3a8 |
nb_sectors = 1;
|
|
|
9ae3a8 |
@@ -1855,7 +1904,7 @@ static int alloc_f(BlockDriverState *bs, int argc, char **argv)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
cvtstr(offset, s1, sizeof(s1));
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- printf("%d/%d sectors allocated at offset %s\n",
|
|
|
9ae3a8 |
+ printf("%"PRId64"/%"PRId64" sectors allocated at offset %s\n",
|
|
|
9ae3a8 |
sum_alloc, nb_sectors, s1);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|