From 0cb1bd0fff0aa76e0af481858e8272ee3b4377a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 18 Jan 2016 23:05:31 +0100 Subject: [PATCH] renderer: do not accept invalid format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That would later crash in util_format_description() or others Fix found thanks to american fuzzy lop. Signed-off-by: Marc-André Lureau --- src/vrend_renderer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index c24b94d..df76637 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -1058,6 +1058,10 @@ int vrend_create_surface(struct vrend_context *ctx, struct vrend_resource *res; uint32_t ret_handle; + if (format >= PIPE_FORMAT_COUNT) { + return EINVAL; + } + res = vrend_renderer_ctx_res_lookup(ctx, res_handle); if (!res) { report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle);