Nikolay Sivov : evr/presenter: Better validate input rectangles in SetVideoPosition().

Alexandre Julliard julliard at winehq.org
Mon Oct 5 15:54:59 CDT 2020


Module: wine
Branch: master
Commit: a419b3eb79741adc9f6f22f84b71ed3e8ae19025
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=a419b3eb79741adc9f6f22f84b71ed3e8ae19025

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon Oct  5 15:26:42 2020 +0300

evr/presenter: Better validate input rectangles in SetVideoPosition().

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 4a7a4021c2..babaca6885 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 48bf01a2ef..0436836963 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);




More information about the wine-cvs mailing list