Module: wine Branch: master Commit: c117d45cb3390d8c12c640ff4191044fd9c8f93b URL: http://source.winehq.org/git/wine.git/?a=commit;h=c117d45cb3390d8c12c640ff41...
Author: Kusanagi Kouichi slash@ac.auone-net.jp Date: Thu Jan 27 01:09:03 2011 +0900
gdi32: Reject invalid character range in GetCharABCWidthsA.
---
dlls/gdi32/font.c | 24 ++++++++++++++++++++---- dlls/gdi32/tests/font.c | 9 --------- 2 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index 5dc2132..b4aa9bc 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..538e983 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -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);