[PATCH 3/5] evr/presenter: Better validate input rectangles in SetVideoPosition().
Nikolay Sivov
nsivov at codeweavers.com
Mon Oct 5 07:26:42 CDT 2020
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/evr/presenter.c | 10 +++++++++-
dlls/evr/tests/evr.c | 24 ++++++++++++++++++++++++
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/dlls/evr/presenter.c b/dlls/evr/presenter.c
index 4a7a4021c28..babaca6885c 100644
--- a/dlls/evr/presenter.c
+++ b/dlls/evr/presenter.c
@@ -510,7 +510,15 @@ static HRESULT WINAPI video_presenter_control_SetVideoPosition(IMFVideoDisplayCo
return E_POINTER;
if (src_rect && (src_rect->left < 0.0f || src_rect->top < 0.0f ||
- src_rect->right > 1.0f || src_rect->bottom > 1.0f))
+ src_rect->right > 1.0f || src_rect->bottom > 1.0f ||
+ src_rect->left > src_rect->right ||
+ src_rect->top > src_rect->bottom))
+ {
+ return E_INVALIDARG;
+ }
+
+ if (dst_rect && (dst_rect->left > dst_rect->right ||
+ dst_rect->top > dst_rect->bottom))
return E_INVALIDARG;
EnterCriticalSection(&presenter->cs);
diff --git a/dlls/evr/tests/evr.c b/dlls/evr/tests/evr.c
index 48bf01a2ef5..0436836963f 100644
--- a/dlls/evr/tests/evr.c
+++ b/dlls/evr/tests/evr.c
@@ -1111,6 +1111,21 @@ static void test_default_presenter(void)
hr = IMFVideoDisplayControl_SetVideoPosition(display_control, &src_rect, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
+ /* Flipped source rectangle. */
+ src_rect.left = 0.5f;
+ src_rect.top = 0.0f;
+ src_rect.right = 0.4f;
+ src_rect.bottom = 1.0f;
+ hr = IMFVideoDisplayControl_SetVideoPosition(display_control, &src_rect, NULL);
+ ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
+
+ src_rect.left = 0.0f;
+ src_rect.top = 0.5f;
+ src_rect.right = 0.4f;
+ src_rect.bottom = 0.1f;
+ hr = IMFVideoDisplayControl_SetVideoPosition(display_control, &src_rect, NULL);
+ ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
+
src_rect.left = 0.1f;
src_rect.top = 0.2f;
src_rect.right = 0.8f;
@@ -1123,6 +1138,15 @@ static void test_default_presenter(void)
ok(src_rect.left == 0.1f && src_rect.top == 0.2f && src_rect.right == 0.8f &&
src_rect.bottom == 0.9f, "Unexpected source rectangle.\n");
+ /* Flipped destination rectangle. */
+ SetRect(&dst_rect, 100, 1, 50, 1000);
+ hr = IMFVideoDisplayControl_SetVideoPosition(display_control, NULL, &dst_rect);
+ ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
+
+ SetRect(&dst_rect, 1, 100, 100, 50);
+ hr = IMFVideoDisplayControl_SetVideoPosition(display_control, NULL, &dst_rect);
+ ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
+
SetRect(&dst_rect, 1, 2, 999, 1000);
hr = IMFVideoDisplayControl_SetVideoPosition(display_control, NULL, &dst_rect);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
--
2.28.0
More information about the wine-devel
mailing list