summaryrefslogtreecommitdiff
path: root/qemu-io-cmds.c
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2015-11-05 18:53:03 -0500
committerKevin Wolf <kwolf@redhat.com>2015-11-11 16:40:10 +0100
commitef5a788527b2038d742b057a415ab4d0e735e98f (patch)
treee873b1a98d237652001f7752844df8ac8243dc85 /qemu-io-cmds.c
parent9b0beaf3de1396a23d5c287283e6f36c4b5d4385 (diff)
downloadqemu-ef5a788527b2038d742b057a415ab4d0e735e98f.tar.gz
qemu-ef5a788527b2038d742b057a415ab4d0e735e98f.tar.bz2
qemu-ef5a788527b2038d742b057a415ab4d0e735e98f.zip
qemu-io: Check for trailing chars
Make sure there's not trailing garbage, e.g. "64k-whatever-i-want-here" Reported-by: Max Reitz <mreitz@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'qemu-io-cmds.c')
-rw-r--r--qemu-io-cmds.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index 1e97f69f56..7ebe89a1d8 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -136,7 +136,14 @@ static char **breakline(char *input, int *count)
static int64_t cvtnum(const char *s)
{
char *end;
- return qemu_strtosz_suffix(s, &end, QEMU_STRTOSZ_DEFSUFFIX_B);
+ int64_t ret;
+
+ ret = qemu_strtosz_suffix(s, &end, QEMU_STRTOSZ_DEFSUFFIX_B);
+ if (*end != '\0') {
+ /* Detritus at the end of the string */
+ return -EINVAL;
+ }
+ return ret;
}
#define EXABYTES(x) ((long long)(x) << 60)