Added patch to make sure CompareString immediately aborts on first non-matching character.

This commit is contained in:
Sebastian Lackner 2015-11-14 20:50:18 +01:00
parent cfc2f08f0a
commit 03fc84498f
6 changed files with 121 additions and 1 deletions

View File

@ -34,11 +34,12 @@ Wine. All those differences are also documented on the
Included bug fixes and improvements
-----------------------------------
**Bug fixes and features included in the next upcoming release [8]:**
**Bug fixes and features included in the next upcoming release [9]:**
* Add partial implementation of ITfThreadMgrEx_ActivateEx ([Wine Bug #39564](https://bugs.winehq.org/show_bug.cgi?id=39564))
* Add stub kernel32.FreeUserPhysicalPages ([Wine Bug #39543](https://bugs.winehq.org/show_bug.cgi?id=39543))
* Add stubs for advapi32.RegCreateKeyTransacted[A/W]
* CompareString should abort on first non-matching character ([Wine Bug #37556](https://bugs.winehq.org/show_bug.cgi?id=37556))
* Do not require SeBackupPrivilege in load_registry and unload_registry ([Wine Bug #28729](https://bugs.winehq.org/show_bug.cgi?id=28729))
* Implement stub for hid.HidP_TranslateUsagesToI8042ScanCodes ([Wine Bug #39447](https://bugs.winehq.org/show_bug.cgi?id=39447))
* Implement support for "Purist Mode" (override for all dlls)

2
debian/changelog vendored
View File

@ -9,6 +9,8 @@ wine-staging (1.7.55) UNRELEASED; urgency=low
* Added patch for stubs of advapi32.RegCreateKeyTransacted[A/W].
* Added patch to fix required privileges for load_registry and unload_registry
wineserver call.
* Added patch to make sure CompareString immediately aborts on first non-
matching character.
* Remove disabled shell32-Quoted_ShellExecute patchset (bug already fixed and
all tests pass).
* Remove disabled reg-Cleanup patchset (only cleanup and not actively

View File

@ -0,0 +1,64 @@
From 8e2f184541d44755fa67a43e4d8cf8debeeafc82 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Fri, 13 Nov 2015 20:36:54 +0800
Subject: kernel32: CompareStringW should abort on the first nonmatching
character to avoid invalid memory access.
For bug 37556.
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
---
libs/wine/sortkey.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/libs/wine/sortkey.c b/libs/wine/sortkey.c
index 17b5537..c459cea 100644
--- a/libs/wine/sortkey.c
+++ b/libs/wine/sortkey.c
@@ -223,6 +223,8 @@ static inline int compare_unicode_weights(int flags, const WCHAR *str1, int len1
len1--;
len2--;
}
+ if (len1 && !*str1) len1--;
+ if (len2 && !*str2) len2--;
return len1 - len2;
}
@@ -272,6 +274,8 @@ static inline int compare_diacritic_weights(int flags, const WCHAR *str1, int le
len1--;
len2--;
}
+ if (len1 && !*str1) len1--;
+ if (len2 && !*str2) len2--;
return len1 - len2;
}
@@ -321,23 +325,16 @@ static inline int compare_case_weights(int flags, const WCHAR *str1, int len1,
len1--;
len2--;
}
+ if (len1 && !*str1) len1--;
+ if (len2 && !*str2) len2--;
return len1 - len2;
}
-static inline int real_length(const WCHAR *str, int len)
-{
- while (len && !str[len - 1]) len--;
- return len;
-}
-
int wine_compare_string(int flags, const WCHAR *str1, int len1,
const WCHAR *str2, int len2)
{
int ret;
- len1 = real_length(str1, len1);
- len2 = real_length(str2, len2);
-
ret = compare_unicode_weights(flags, str1, len1, str2, len2);
if (!ret)
{
--
2.6.2

View File

@ -0,0 +1,31 @@
From 9261fada866235424392ac94d78e2d3a3a02ecc7 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 14 Nov 2015 20:43:39 +0100
Subject: kernel32/tests: Add some more tests for NORM_IGNORESYMBOLS.
---
dlls/kernel32/tests/locale.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c
index 7b0212e..a70dc13 100644
--- a/dlls/kernel32/tests/locale.c
+++ b/dlls/kernel32/tests/locale.c
@@ -1634,7 +1634,13 @@ static const struct comparestringa_entry comparestringa_data[] = {
{ LOCALE_SYSTEM_DEFAULT, SORT_STRINGSORT, "'o", -1, "/m", -1, CSTR_LESS_THAN },
{ LOCALE_SYSTEM_DEFAULT, SORT_STRINGSORT, "/m", -1, "'o", -1, CSTR_GREATER_THAN },
{ LOCALE_SYSTEM_DEFAULT, 0, "aLuZkUtZ", 8, "aLuZkUtZ", 9, CSTR_EQUAL },
- { LOCALE_SYSTEM_DEFAULT, 0, "aLuZkUtZ", 7, "aLuZkUtZ\0A", 10, CSTR_LESS_THAN }
+ { LOCALE_SYSTEM_DEFAULT, 0, "aLuZkUtZ", 7, "aLuZkUtZ\0A", 10, CSTR_LESS_THAN },
+ { LOCALE_SYSTEM_DEFAULT, 0, "a-", 3, "a\0", 3, CSTR_GREATER_THAN },
+ { LOCALE_SYSTEM_DEFAULT, 0, "a'", 3, "a\0", 3, CSTR_GREATER_THAN },
+ { LOCALE_SYSTEM_DEFAULT, SORT_STRINGSORT, "a-", 3, "a\0", 3, CSTR_GREATER_THAN },
+ { LOCALE_SYSTEM_DEFAULT, SORT_STRINGSORT, "a'", 3, "a\0", 3, CSTR_GREATER_THAN },
+ { LOCALE_SYSTEM_DEFAULT, NORM_IGNORESYMBOLS, "a.", 3, "a\0", 3, CSTR_EQUAL },
+ { LOCALE_SYSTEM_DEFAULT, NORM_IGNORESYMBOLS, "a ", 3, "a\0", 3, CSTR_EQUAL },
};
static void test_CompareStringA(void)
--
2.6.2

View File

@ -0,0 +1 @@
Fixes: [37556] CompareString should abort on first non-matching character

View File

@ -151,6 +151,7 @@ patch_enable_all ()
enable_kernel32_COMSPEC="$1"
enable_kernel32_Codepage_Conversion="$1"
enable_kernel32_CompareStringEx="$1"
enable_kernel32_CompareString_Length="$1"
enable_kernel32_CopyFileEx="$1"
enable_kernel32_Cwd_Startup_Info="$1"
enable_kernel32_FreeUserPhysicalPages="$1"
@ -557,6 +558,9 @@ patch_enable ()
kernel32-CompareStringEx)
enable_kernel32_CompareStringEx="$2"
;;
kernel32-CompareString_Length)
enable_kernel32_CompareString_Length="$2"
;;
kernel32-CopyFileEx)
enable_kernel32_CopyFileEx="$2"
;;
@ -3325,6 +3329,23 @@ if test "$enable_kernel32_CompareStringEx" -eq 1; then
) >> "$patchlist"
fi
# Patchset kernel32-CompareString_Length
# |
# | This patchset fixes the following Wine bugs:
# | * [#37556] CompareString should abort on first non-matching character
# |
# | Modified files:
# | * dlls/kernel32/tests/locale.c, libs/wine/sortkey.c
# |
if test "$enable_kernel32_CompareString_Length" -eq 1; then
patch_apply kernel32-CompareString_Length/0001-kernel32-CompareStringW-should-abort-on-the-first-no.patch
patch_apply kernel32-CompareString_Length/0002-kernel32-tests-Add-some-more-tests-for-NORM_IGNORESY.patch
(
echo '+ { "Dmitry Timoshkov", "kernel32: CompareStringW should abort on the first nonmatching character to avoid invalid memory access.", 1 },';
echo '+ { "Sebastian Lackner", "kernel32/tests: Add some more tests for NORM_IGNORESYMBOLS.", 1 },';
) >> "$patchlist"
fi
# Patchset kernel32-SetFileInformationByHandle
# |
# | Modified files: