Skip to content

Commit

Permalink
qapi: Check for negative enum values
Browse files Browse the repository at this point in the history
We don't currently check for negative enum values in qmp_output_type_enum(),
this will very likely generate a segfault when triggered.

However, it _seems_ that no code in tree can trigger this today.

Acked-by: Michael Roth <[email protected]>
Signed-off-by: Luiz Capitulino <[email protected]>
  • Loading branch information
Luiz Capitulino committed Nov 17, 2011
1 parent 3f5bd4e commit 54d50be
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion qapi/qmp-output-visitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ static void qmp_output_type_enum(Visitor *v, int *obj, const char *strings[],

assert(strings);
while (strings[i++] != NULL);
if (value >= i - 1) {
if (value < 0 || value >= i - 1) {
error_set(errp, QERR_INVALID_PARAMETER, name ? name : "null");
return;
}
Expand Down

0 comments on commit 54d50be

Please sign in to comment.