=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: vkd3d: Validate sub-resource index in d3d12_resource_Map().
Alexandre Julliard
julliard at winehq.org
Tue Nov 13 13:54:58 CST 2018
Module: vkd3d
Branch: master
Commit: 91c11eed03d320e8713e0566854d02e47c1cc4f9
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=91c11eed03d320e8713e0566854d02e47c1cc4f9
Author: Józef Kucia <jkucia at codeweavers.com>
Date: Tue Nov 13 00:23:27 2018 +0100
vkd3d: Validate sub-resource index in d3d12_resource_Map().
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
libs/vkd3d/resource.c | 8 ++++++++
libs/vkd3d/vkd3d_private.h | 5 +++++
2 files changed, 13 insertions(+)
diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c
index be8bbed..80e7319 100644
--- a/libs/vkd3d/resource.c
+++ b/libs/vkd3d/resource.c
@@ -811,6 +811,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource *iface, UINT
const D3D12_RANGE *read_range, void **data)
{
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
+ unsigned int sub_resource_count;
struct d3d12_device *device;
VkResult vr;
HRESULT hr;
@@ -826,6 +827,13 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource *iface, UINT
return E_INVALIDARG;
}
+ sub_resource_count = d3d12_resource_desc_get_sub_resource_count(&resource->desc);
+ if (sub_resource >= sub_resource_count)
+ {
+ WARN("Sub-resource index %u is out of range (%u sub-resources).\n", sub_resource, sub_resource_count);
+ return E_INVALIDARG;
+ }
+
if (d3d12_resource_is_texture(resource))
{
/* Textures seem to be mappable only on UMA adapters. */
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index d6c821b..daa60cb 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -861,6 +861,11 @@ static inline unsigned int d3d12_resource_desc_get_layer_count(const D3D12_RESOU
return desc->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? desc->DepthOrArraySize : 1;
}
+static inline unsigned int d3d12_resource_desc_get_sub_resource_count(const D3D12_RESOURCE_DESC *desc)
+{
+ return d3d12_resource_desc_get_layer_count(desc) * desc->MipLevels;
+}
+
enum VkCompareOp vk_compare_op_from_d3d12(D3D12_COMPARISON_FUNC op) DECLSPEC_HIDDEN;
VkSampleCountFlagBits vk_samples_from_dxgi_sample_desc(const DXGI_SAMPLE_DESC *desc) DECLSPEC_HIDDEN;
More information about the wine-cvs
mailing list