mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-09-13 09:17:20 -07:00
kernel32-CompareString_Length: Update patchset to correctly handle comparison of strings ending with multiple \0 characters.
This commit is contained in:
parent
2413df39ed
commit
d924f74e90
@ -1,44 +1,72 @@
|
||||
From 8e2f184541d44755fa67a43e4d8cf8debeeafc82 Mon Sep 17 00:00:00 2001
|
||||
From f8acf44d20407c213dd1f48691b432c2e9f555df 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.
|
||||
character to avoid invalid memory access. (v2)
|
||||
|
||||
For bug 37556.
|
||||
|
||||
Changes in v2 (by Sebastian Lackner):
|
||||
* Use loop to handle strings ending with multiple \0 characters correctly.
|
||||
|
||||
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
|
||||
---
|
||||
libs/wine/sortkey.c | 15 ++++++---------
|
||||
1 file changed, 6 insertions(+), 9 deletions(-)
|
||||
libs/wine/sortkey.c | 39 ++++++++++++++++++++++++++++++---------
|
||||
1 file changed, 30 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/libs/wine/sortkey.c b/libs/wine/sortkey.c
|
||||
index 17b5537..c459cea 100644
|
||||
index 17b5537..7280501 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
|
||||
@@ -223,6 +223,16 @@ static inline int compare_unicode_weights(int flags, const WCHAR *str1, int len1
|
||||
len1--;
|
||||
len2--;
|
||||
}
|
||||
+ if (len1 && !*str1) len1--;
|
||||
+ if (len2 && !*str2) len2--;
|
||||
+ while (len1 && !*str1)
|
||||
+ {
|
||||
+ str1++;
|
||||
+ len1--;
|
||||
+ }
|
||||
+ while (len2 && !*str2)
|
||||
+ {
|
||||
+ str2++;
|
||||
+ len2--;
|
||||
+ }
|
||||
return len1 - len2;
|
||||
}
|
||||
|
||||
@@ -272,6 +274,8 @@ static inline int compare_diacritic_weights(int flags, const WCHAR *str1, int le
|
||||
@@ -272,6 +282,16 @@ static inline int compare_diacritic_weights(int flags, const WCHAR *str1, int le
|
||||
len1--;
|
||||
len2--;
|
||||
}
|
||||
+ if (len1 && !*str1) len1--;
|
||||
+ if (len2 && !*str2) len2--;
|
||||
+ while (len1 && !*str1)
|
||||
+ {
|
||||
+ str1++;
|
||||
+ len1--;
|
||||
+ }
|
||||
+ while (len2 && !*str2)
|
||||
+ {
|
||||
+ str2++;
|
||||
+ len2--;
|
||||
+ }
|
||||
return len1 - len2;
|
||||
}
|
||||
|
||||
@@ -321,23 +325,16 @@ static inline int compare_case_weights(int flags, const WCHAR *str1, int len1,
|
||||
@@ -321,23 +341,24 @@ static inline int compare_case_weights(int flags, const WCHAR *str1, int len1,
|
||||
len1--;
|
||||
len2--;
|
||||
}
|
||||
+ if (len1 && !*str1) len1--;
|
||||
+ if (len2 && !*str2) len2--;
|
||||
+ while (len1 && !*str1)
|
||||
+ {
|
||||
+ str1++;
|
||||
+ len1--;
|
||||
+ }
|
||||
+ while (len2 && !*str2)
|
||||
+ {
|
||||
+ str2++;
|
||||
+ len2--;
|
||||
+ }
|
||||
return len1 - len2;
|
||||
}
|
||||
|
||||
@ -60,5 +88,5 @@ index 17b5537..c459cea 100644
|
||||
if (!ret)
|
||||
{
|
||||
--
|
||||
2.6.2
|
||||
2.6.4
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
From c855cfddc7853fa8aed1ce4aac9a85c7ff7cb1f1 Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Lackner <sebastian@fds-team.de>
|
||||
Date: Fri, 22 Jan 2016 15:13:36 +0100
|
||||
Subject: kenrel32/tests: Add further tests for comparing strings ending with
|
||||
multiple \0 characters.
|
||||
|
||||
---
|
||||
dlls/kernel32/tests/locale.c | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c
|
||||
index d531272..4a9e540 100644
|
||||
--- a/dlls/kernel32/tests/locale.c
|
||||
+++ b/dlls/kernel32/tests/locale.c
|
||||
@@ -1643,6 +1643,14 @@ static const struct comparestringa_entry comparestringa_data[] = {
|
||||
{ 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 },
|
||||
+ { LOCALE_SYSTEM_DEFAULT, 0, "a", 1, "a\0\0", 4, CSTR_EQUAL },
|
||||
+ { LOCALE_SYSTEM_DEFAULT, 0, "a", 2, "a\0\0", 4, CSTR_EQUAL },
|
||||
+ { LOCALE_SYSTEM_DEFAULT, 0, "a\0\0", 4, "a", 1, CSTR_EQUAL },
|
||||
+ { LOCALE_SYSTEM_DEFAULT, 0, "a\0\0", 4, "a", 2, CSTR_EQUAL },
|
||||
+ { LOCALE_SYSTEM_DEFAULT, 0, "a", 1, "a\0x", 4, CSTR_LESS_THAN },
|
||||
+ { LOCALE_SYSTEM_DEFAULT, 0, "a", 2, "a\0x", 4, CSTR_LESS_THAN },
|
||||
+ { LOCALE_SYSTEM_DEFAULT, 0, "a\0x", 4, "a", 1, CSTR_GREATER_THAN },
|
||||
+ { LOCALE_SYSTEM_DEFAULT, 0, "a\0x", 4, "a", 2, CSTR_GREATER_THAN },
|
||||
};
|
||||
|
||||
static void test_CompareStringA(void)
|
||||
--
|
||||
2.6.4
|
||||
|
@ -3735,9 +3735,11 @@ fi
|
||||
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
|
||||
patch_apply kernel32-CompareString_Length/0003-kenrel32-tests-Add-further-tests-for-comparing-strin.patch
|
||||
(
|
||||
echo '+ { "Dmitry Timoshkov", "kernel32: CompareStringW should abort on the first nonmatching character to avoid invalid memory access.", 1 },';
|
||||
echo '+ { "Dmitry Timoshkov", "kernel32: CompareStringW should abort on the first nonmatching character to avoid invalid memory access.", 2 },';
|
||||
echo '+ { "Sebastian Lackner", "kernel32/tests: Add some more tests for NORM_IGNORESYMBOLS.", 1 },';
|
||||
echo '+ { "Sebastian Lackner", "kenrel32/tests: Add further tests for comparing strings ending with multiple \\\\0 characters.", 1 },';
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user