[3/4] gdi32: Reject invalid cahacter range in GetCharABCWidthsA.

Kusanagi Kouichi slash at ac.auone-net.jp
Wed Jan 26 10:09:03 CST 2011


Signed-off-by: Kusanagi Kouichi <slash at ac.auone-net.jp>
---
 dlls/gdi32/font.c       |   24 ++++++++++++++++++++----
 dlls/gdi32/tests/font.c |    8 --------
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index d9fae76..d8cade7 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -1553,7 +1553,7 @@ UINT WINAPI GetOutlineTextMetricsW(
     return ret;
 }
 
-static LPSTR FONT_GetCharsByRangeA(UINT firstChar, UINT lastChar, PINT pByteLen)
+static LPSTR FONT_GetCharsByRangeA(HDC hdc, UINT firstChar, UINT lastChar, PINT pByteLen)
 {
     INT i, count = lastChar - firstChar + 1;
     UINT c;
@@ -1562,6 +1562,22 @@ static LPSTR FONT_GetCharsByRangeA(UINT firstChar, UINT lastChar, PINT pByteLen)
     if (count <= 0)
         return NULL;
 
+    switch (GdiGetCodePage(hdc))
+    {
+    case 932:
+    case 936:
+    case 949:
+    case 950:
+    case 1361:
+        if (lastChar > 0xffff)
+            return NULL;
+        break;
+    default:
+        if (lastChar > 0xff)
+            return NULL;
+        break;
+    }
+
     str = HeapAlloc(GetProcessHeap(), 0, count * 2 + 1);
     if (str == NULL)
         return NULL;
@@ -1620,7 +1636,7 @@ BOOL WINAPI GetCharWidth32A( HDC hdc, UINT firstChar, UINT lastChar,
     LPWSTR wstr;
     BOOL ret = TRUE;
 
-    str = FONT_GetCharsByRangeA(firstChar, lastChar, &i);
+    str = FONT_GetCharsByRangeA(hdc, firstChar, lastChar, &i);
     if(str == NULL)
         return FALSE;
 
@@ -2324,7 +2340,7 @@ BOOL WINAPI GetCharABCWidthsA(HDC hdc, UINT firstChar, UINT lastChar,
     LPWSTR wstr;
     BOOL ret = TRUE;
 
-    str = FONT_GetCharsByRangeA(firstChar, lastChar, &i);
+    str = FONT_GetCharsByRangeA(hdc, firstChar, lastChar, &i);
     if (str == NULL)
         return FALSE;
 
@@ -3010,7 +3026,7 @@ BOOL WINAPI GetCharABCWidthsFloatA( HDC hdc, UINT first, UINT last, LPABCFLOAT a
     LPWSTR wstr;
     BOOL ret = TRUE;
 
-    str = FONT_GetCharsByRangeA(first, last, &i);
+    str = FONT_GetCharsByRangeA(hdc, first, last, &i);
     if (str == NULL)
         return FALSE;
 
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
index 564a420..246cb66 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -1011,7 +1011,6 @@ static void test_GetCharABCWidths(void)
         ok(ret == c[i].r[0], "GetCharABCWidthsA should have %s\n", c[i].r[0] ? "succeeded" : "failed");
 
         ret = pGetCharABCWidthsA(hdc, 0x100, 0x100, abc);
-        todo_wine
         ok(ret == c[i].r[1], "GetCharABCWidthsA should have %s\n", c[i].r[1] ? "succeeded" : "failed");
 
         ret = pGetCharABCWidthsA(hdc, 0xff, 0x100, a);
@@ -1019,31 +1018,24 @@ static void test_GetCharABCWidths(void)
         ok(ret == c[i].r[2], "GetCharABCWidthsA should have %s\n", c[i].r[2] ? "succeeded" : "failed");
 
         ret = pGetCharABCWidthsA(hdc, 0xffff, 0xffff, abc);
-        todo_wine
         ok(ret == c[i].r[3], "GetCharABCWidthsA should have %s\n", c[i].r[3] ? "succeeded" : "failed");
 
         ret = pGetCharABCWidthsA(hdc, 0x10000, 0x10000, abc);
-        todo_wine
         ok(ret == c[i].r[4], "GetCharABCWidthsA should have %s\n", c[i].r[4] ? "succeeded" : "failed");
 
         ret = pGetCharABCWidthsA(hdc, 0xffff, 0x10000, a);
-        todo_wine
         ok(ret == c[i].r[5], "GetCharABCWidthsA should have %s\n", c[i].r[5] ? "succeeded" : "failed");
 
         ret = pGetCharABCWidthsA(hdc, 0xffffff, 0xffffff, abc);
-        todo_wine
         ok(ret == c[i].r[6], "GetCharABCWidthsA should have %s\n", c[i].r[6] ? "succeeded" : "failed");
 
         ret = pGetCharABCWidthsA(hdc, 0x1000000, 0x1000000, abc);
-        todo_wine
         ok(ret == c[i].r[7], "GetCharABCWidthsA should have %s\n", c[i].r[7] ? "succeeded" : "failed");
 
         ret = pGetCharABCWidthsA(hdc, 0xffffff, 0x1000000, a);
-        todo_wine
         ok(ret == c[i].r[8], "GetCharABCWidthsA should have %s\n", c[i].r[8] ? "succeeded" : "failed");
 
         ret = pGetCharABCWidthsA(hdc, 0xffffffff, 0xffffffff, abc);
-        todo_wine
         ok(ret == c[i].r[9], "GetCharABCWidthsA should have %s\n", c[i].r[9] ? "succeeded" : "failed");
 
         hfont = SelectObject(hdc, hfont);
-- 
1.7.2.3




More information about the wine-patches mailing list