Revision 15a849be
b/include/qapi/opts-visitor.h | ||
---|---|---|
16 | 16 |
#include "qapi/visitor.h" |
17 | 17 |
#include "qemu/option.h" |
18 | 18 |
|
19 |
/* Inclusive upper bound on the size of any flattened range. This is a safety |
|
20 |
* (= anti-annoyance) measure; wrong ranges should not cause long startup |
|
21 |
* delays nor exhaust virtual memory. |
|
22 |
*/ |
|
23 |
#define OPTS_VISITOR_RANGE_MAX 65536 |
|
24 |
|
|
19 | 25 |
typedef struct OptsVisitor OptsVisitor; |
20 | 26 |
|
21 | 27 |
/* Contrarily to qemu-option.c::parse_option_number(), OptsVisitor's "int" |
b/qapi/opts-visitor.c | ||
---|---|---|
384 | 384 |
str = endptr + 1; |
385 | 385 |
val2 = strtoll(str, &endptr, 0); |
386 | 386 |
if (errno == 0 && endptr > str && *endptr == '\0' && |
387 |
INT64_MIN <= val2 && val2 <= INT64_MAX && val <= val2) { |
|
387 |
INT64_MIN <= val2 && val2 <= INT64_MAX && val <= val2 && |
|
388 |
(val > INT64_MAX - OPTS_VISITOR_RANGE_MAX || |
|
389 |
val2 < val + OPTS_VISITOR_RANGE_MAX)) { |
|
388 | 390 |
ov->range_next.s = val; |
389 | 391 |
ov->range_limit.s = val2; |
390 | 392 |
ov->list_mode = LM_SIGNED_INTERVAL; |
... | ... | |
435 | 437 |
|
436 | 438 |
str = endptr + 1; |
437 | 439 |
if (parse_uint_full(str, &val2, 0) == 0 && |
438 |
val2 <= UINT64_MAX && val <= val2) { |
|
440 |
val2 <= UINT64_MAX && val <= val2 && |
|
441 |
val2 - val < OPTS_VISITOR_RANGE_MAX) { |
|
439 | 442 |
ov->range_next.u = val; |
440 | 443 |
ov->range_limit.u = val2; |
441 | 444 |
ov->list_mode = LM_UNSIGNED_INTERVAL; |
Also available in: Unified diff