From e49b4445d166821161b8e4b95ad2f65c26fe5ef4 Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Mon, 14 Nov 2011 11:25:09 -0200 Subject: [PATCH] qapi: Check for negative enum values 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 Signed-off-by: Luiz Capitulino --- qapi/qmp-output-visitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c index d67724e..f76d015 100644 --- a/qapi/qmp-output-visitor.c +++ b/qapi/qmp-output-visitor.c @@ -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; } -- 2.7.4