mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-18 14:47:17 +00:00
qapi: Fix string-input-visitor to reject NaN and infinities
The string-input-visitor happily accepts NaN and infinities when parsing numbers (doubles). They shouldn't. Fix that. Also, add two test cases, testing if "NaN" and "inf" is properly rejected. Backports commit 4b69d4c3d7c133ebc9393ef3f86ce38831921cb6 from qemu
This commit is contained in:
parent
67f9141b13
commit
d2e0fae69b
|
@ -19,6 +19,7 @@
|
||||||
#include "qapi/qmp/qnull.h"
|
#include "qapi/qmp/qnull.h"
|
||||||
#include "qemu/queue.h"
|
#include "qemu/queue.h"
|
||||||
#include "qemu/range.h"
|
#include "qemu/range.h"
|
||||||
|
#include "qemu/cutils.h"
|
||||||
#include <stdlib.h> // strtoll
|
#include <stdlib.h> // strtoll
|
||||||
|
|
||||||
|
|
||||||
|
@ -297,12 +298,9 @@ static void parse_type_number(Visitor *v, const char *name, double *obj,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
StringInputVisitor *siv = to_siv(v);
|
StringInputVisitor *siv = to_siv(v);
|
||||||
char *endp = (char *) siv->string;
|
|
||||||
double val;
|
double val;
|
||||||
|
|
||||||
errno = 0;
|
if (qemu_strtod_finite(siv->string, NULL, &val)) {
|
||||||
val = strtod(siv->string, &endp);
|
|
||||||
if (errno || endp == siv->string || *endp) {
|
|
||||||
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
|
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
|
||||||
"number");
|
"number");
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue