gdi32: Reject invalid character range in GetCharABCWidthsA.
authorKusanagi Kouichi <slash@ac.auone-net.jp>
Wed, 26 Jan 2011 16:09:03 +0000 (01:09 +0900)
committerAlexandre Julliard <julliard@winehq.org>
Fri, 28 Jan 2011 13:50:20 +0000 (14:50 +0100)
dlls/gdi32/font.c
dlls/gdi32/tests/font.c

index 5dc213222b30d320a3562d7b208c86728cf42b98..b4aa9bc1836c9ea463206a473669a62600907729 100644 (file)
@@ -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;
 
index 564a42077100abf1db09b82183f2b4fc82978d14..538e983ccc7e0980a69e5031f22c8a607db1bbe0 100644 (file)
@@ -1011,39 +1011,30 @@ 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);
-        todo_wine
         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);