Added patch to fix access violation when calling GetStringTypeW with NULL src.

This commit is contained in:
Sebastian Lackner
2014-12-27 23:08:41 +01:00
parent 1944c4b4e8
commit bbd04d95a2
5 changed files with 77 additions and 1 deletions

View File

@@ -53,6 +53,7 @@ PATCHLIST := \
iphlpapi-TCP_Table.ok \
kernel32-GetFinalPathNameByHandle.ok \
kernel32-GetNumaProcessorNode.ok \
kernel32-GetStringTypeW.ok \
kernel32-GetSystemTimes.ok \
kernel32-GetVolumePathName.ok \
kernel32-Named_Pipe.ok \
@@ -735,6 +736,21 @@ kernel32-GetNumaProcessorNode.ok:
echo '+ { "Michael Müller", "kernel32/tests: Add tests for GetNumaProcessorNode.", 1 },'; \
) > kernel32-GetNumaProcessorNode.ok
# Patchset kernel32-GetStringTypeW
# |
# | This patchset fixes the following Wine bugs:
# | * [#37759] Fix access violation when calling GetStringTypeW with NULL src.
# |
# | Modified files:
# | * dlls/kernel32/locale.c, dlls/kernel32/tests/locale.c
# |
.INTERMEDIATE: kernel32-GetStringTypeW.ok
kernel32-GetStringTypeW.ok:
$(call APPLY_FILE,kernel32-GetStringTypeW/0001-kernel32-Allow-empty-source-in-GetStringTypeW.patch)
@( \
echo '+ { "Christian Faure", "kernel32: Allow empty source in GetStringTypeW.", 1 },'; \
) > kernel32-GetStringTypeW.ok
# Patchset kernel32-GetSystemTimes
# |
# | This patchset fixes the following Wine bugs:

View File

@@ -0,0 +1,57 @@
From 62e504c9dcad87ffd419b5bb157c88342934ff61 Mon Sep 17 00:00:00 2001
From: Christian Faure <christian.faurebouvard@gmail.com>
Date: Tue, 23 Dec 2014 13:13:49 -0300
Subject: kernel32: Allow empty source in GetStringTypeW.
---
dlls/kernel32/locale.c | 5 +++++
dlls/kernel32/tests/locale.c | 10 ++++++++++
2 files changed, 15 insertions(+)
diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c
index 1460f7a..30f9048 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -2479,6 +2479,11 @@ BOOL WINAPI GetStringTypeW( DWORD type, LPCWSTR src, INT count, LPWORD chartype
C2_OTHERNEUTRAL /* LRE, LRO, RLE, RLO, PDF */
};
+ if (!src) /* Abort and return FALSE when src is null */
+ {
+ SetLastError( ERROR_INVALID_PARAMETER );
+ return FALSE;
+ }
if (count == -1) count = strlenW(src) + 1;
switch(type)
{
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c
index 65172a7..24b541a 100644
--- a/dlls/kernel32/tests/locale.c
+++ b/dlls/kernel32/tests/locale.c
@@ -3281,6 +3281,7 @@ static void test_GetStringTypeW(void)
WORD types[20];
WCHAR ch;
+ BOOL res;
int i;
memset(types,0,sizeof(types));
@@ -3338,6 +3339,15 @@ static void test_GetStringTypeW(void)
for (i = 0; i < 3; i++)
ok(types[i] & C1_SPACE || broken(types[i] == C1_CNTRL) || broken(types[i] == 0), "incorrect types returned for %x -> (%x does not have %x)\n",space_special[i], types[i], C1_SPACE );
+ for (i = -1; i < 3; i++)
+ {
+ SetLastError(0xdeadbeef);
+ memset(types, 0, sizeof(types));
+ res = GetStringTypeW(CT_CTYPE1, NULL, i, types);
+ ok(!res, "GetStringTypeW unexpectedly succeeded\n");
+ ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error, got %u\n", GetLastError());
+ }
+
/* surrogate pairs */
ch = 0xd800;
memset(types, 0, sizeof(types));
--
2.1.3

View File

@@ -0,0 +1 @@
Fixes: [37759] Fix access violation when calling GetStringTypeW with NULL src.