提交 ef5a7885 编写于 作者: J John Snow 提交者: Kevin Wolf

qemu-io: Check for trailing chars

Make sure there's not trailing garbage, e.g.
"64k-whatever-i-want-here"
Reported-by: NMax Reitz <mreitz@redhat.com>
Signed-off-by: NJohn Snow <jsnow@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Reviewed-by: NKevin Wolf <kwolf@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 9b0beaf3
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册