From 0d21bab68461b8cd782109d32541ccf289bfc887 Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Mon, 5 Mar 2012 17:44:24 -0500 Subject: [PATCH 57/98] 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 (cherry picked from commit 54d50be688aba80e0fd5ba53f23a074a0ce2e381) Signed-off-by: Jeff Cody Signed-off-by: Michal Novotny --- qapi/qmp-output-visitor.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c index 31643ee..4441511 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; } -- 1.7.7.6