File 0004-24f67de-vrend-check-info-formats-in-blits.patch of Package virglrenderer
commit 24f67de7a9088a873844a39be03cee6882260ac9
Author: Gert Wollny <gert.wollny@collabora.com>
Date: Mon Oct 7 10:59:56 2019 +0200
vrend: check info formats in blits
Closes #141
Closes #142
v2 : drop colon in error description (Emil)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Index: virglrenderer-0.6.0/src/virgl_hw.h
===================================================================
--- virglrenderer-0.6.0.orig/src/virgl_hw.h
+++ virglrenderer-0.6.0/src/virgl_hw.h
@@ -270,6 +270,7 @@ enum virgl_ctx_errors {
VIRGL_ERROR_CTX_ILLEGAL_SURFACE,
VIRGL_ERROR_CTX_ILLEGAL_VERTEX_FORMAT,
VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER,
+ VIRGL_ERROR_CTX_ILLEGAL_FORMAT,
};
Index: virglrenderer-0.6.0/src/vrend_renderer.c
===================================================================
--- virglrenderer-0.6.0.orig/src/vrend_renderer.c
+++ virglrenderer-0.6.0/src/vrend_renderer.c
@@ -461,7 +461,7 @@ static inline const char *pipe_shader_to
};
}
-static const char *vrend_ctx_error_strings[] = { "None", "Unknown", "Illegal shader", "Illegal handle", "Illegal resource", "Illegal surface", "Illegal vertex format", "Illegal command buffer" };
+static const char *vrend_ctx_error_strings[] = { "None", "Unknown", "Illegal shader", "Illegal handle", "Illegal resource", "Illegal surface", "Illegal vertex format", "Illegal command buffer", "Illegal format ID" };
static void __report_context_error(const char *fname, struct vrend_context *ctx, enum virgl_ctx_errors error, uint32_t value)
{
@@ -5660,6 +5660,16 @@ void vrend_renderer_blit(struct vrend_co
if (ctx->in_error)
return;
+ if (!info->src.format || (enum virgl_formats)info->src.format >= VIRGL_FORMAT_MAX) {
+ report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_FORMAT, info->src.format);
+ return;
+ }
+
+ if (!info->dst.format || (enum virgl_formats)info->dst.format >= VIRGL_FORMAT_MAX) {
+ report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_FORMAT, info->dst.format);
+ return;
+ }
+
if (info->render_condition_enable == false)
vrend_pause_render_condition(ctx, true);