From 29287d3368f70b57d05c4ae2e2c937ebbb539236 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 23 Jul 2020 13:41:29 +0430 Subject: [PATCH] vkd3d-shader: Add compiler messages for invalid DXBC chunk offsets and sizes. Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- libs/vkd3d-shader/dxbc.c | 5 +++++ libs/vkd3d-shader/vkd3d_shader_private.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 8e5c49c5..f738abe2 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -2015,6 +2015,8 @@ static int parse_dxbc(const char *data, size_t data_size, struct vkd3d_shader_me if (chunk_offset >= data_size || !require_space(chunk_offset, 2, sizeof(DWORD), data_size)) { WARN("Invalid chunk offset %#x (data size %zu).\n", chunk_offset, data_size); + vkd3d_shader_error(message_context, VKD3D_SHADER_ERROR_DXBC_INVALID_CHUNK_OFFSET, + "DXBC chunk %u has invalid offset %#x (data size %#zx).", i, chunk_offset, data_size); return VKD3D_ERROR_INVALID_ARGUMENT; } @@ -2027,6 +2029,9 @@ static int parse_dxbc(const char *data, size_t data_size, struct vkd3d_shader_me { WARN("Invalid chunk size %#x (data size %zu, chunk offset %#x).\n", chunk_size, data_size, chunk_offset); + vkd3d_shader_error(message_context, VKD3D_SHADER_ERROR_DXBC_INVALID_CHUNK_SIZE, + "DXBC chunk %u has invalid size %#x (data size %#zx, chunk offset %#x).", + i, chunk_offset, data_size, chunk_offset); return VKD3D_ERROR_INVALID_ARGUMENT; } diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index f9bd6ab1..c6796bb4 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -65,6 +65,8 @@ enum vkd3d_shader_error VKD3D_SHADER_ERROR_DXBC_INVALID_MAGIC = 2, VKD3D_SHADER_ERROR_DXBC_INVALID_CHECKSUM = 3, VKD3D_SHADER_ERROR_DXBC_INVALID_VERSION = 4, + VKD3D_SHADER_ERROR_DXBC_INVALID_CHUNK_OFFSET = 5, + VKD3D_SHADER_ERROR_DXBC_INVALID_CHUNK_SIZE = 6, }; enum VKD3D_SHADER_INSTRUCTION_HANDLER