Skip to content

Commit

Permalink
qemu-io: Check for trailing chars
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jnsnow authored and kevmw committed Nov 11, 2015
1 parent 9b0beaf commit ef5a788
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion qemu-io-cmds.c
Expand Up @@ -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)
Expand Down

0 comments on commit ef5a788

Please sign in to comment.