Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
ed61ff43
Commit
ed61ff43
authored
Mar 20, 2021
by
Gijs Vermeulen
Committed by
Alexandre Julliard
Mar 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase: Reject SORT_DIGITSASNUMBERS in CompareStringA().
Signed-off-by:
Gijs Vermeulen
<
gijsvrm@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
ae3422c6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
13 deletions
+28
-13
locale.c
dlls/kernel32/tests/locale.c
+21
-13
locale.c
dlls/kernelbase/locale.c
+7
-0
No files found.
dlls/kernel32/tests/locale.c
View file @
ed61ff43
...
...
@@ -1790,6 +1790,7 @@ struct comparestringa_entry {
const
char
*
second
;
int
second_len
;
int
ret
;
DWORD
le
;
};
static
const
struct
comparestringa_entry
comparestringa_data
[]
=
{
...
...
@@ -1837,6 +1838,15 @@ static const struct comparestringa_entry comparestringa_data[] = {
{
LOCALE_SYSTEM_DEFAULT
,
0
,
"a"
,
2
,
"a
\0
x"
,
4
,
CSTR_LESS_THAN
},
{
LOCALE_SYSTEM_DEFAULT
,
0
,
"a
\0
x"
,
4
,
"a"
,
1
,
CSTR_GREATER_THAN
},
{
LOCALE_SYSTEM_DEFAULT
,
0
,
"a
\0
x"
,
4
,
"a"
,
2
,
CSTR_GREATER_THAN
},
/* flag tests */
{
LOCALE_SYSTEM_DEFAULT
,
LOCALE_USE_CP_ACP
,
"NULL"
,
-
1
,
"NULL"
,
-
1
,
CSTR_EQUAL
},
{
LOCALE_SYSTEM_DEFAULT
,
LINGUISTIC_IGNORECASE
,
"NULL"
,
-
1
,
"NULL"
,
-
1
,
CSTR_EQUAL
},
{
LOCALE_SYSTEM_DEFAULT
,
LINGUISTIC_IGNOREDIACRITIC
,
"NULL"
,
-
1
,
"NULL"
,
-
1
,
CSTR_EQUAL
},
{
LOCALE_SYSTEM_DEFAULT
,
NORM_IGNOREKANATYPE
,
"NULL"
,
-
1
,
"NULL"
,
-
1
,
CSTR_EQUAL
},
{
LOCALE_SYSTEM_DEFAULT
,
NORM_IGNORENONSPACE
,
"NULL"
,
-
1
,
"NULL"
,
-
1
,
CSTR_EQUAL
},
{
LOCALE_SYSTEM_DEFAULT
,
NORM_IGNOREWIDTH
,
"NULL"
,
-
1
,
"NULL"
,
-
1
,
CSTR_EQUAL
},
{
LOCALE_SYSTEM_DEFAULT
,
NORM_LINGUISTIC_CASING
,
"NULL"
,
-
1
,
"NULL"
,
-
1
,
CSTR_EQUAL
},
{
LOCALE_SYSTEM_DEFAULT
,
SORT_DIGITSASNUMBERS
,
"NULL"
,
-
1
,
"NULL"
,
-
1
,
0
,
ERROR_INVALID_FLAGS
}
};
static
void
test_CompareStringA
(
void
)
...
...
@@ -1851,9 +1861,15 @@ static void test_CompareStringA(void)
{
const
struct
comparestringa_entry
*
entry
=
&
comparestringa_data
[
i
];
SetLastError
(
0xdeadbeef
);
ret
=
CompareStringA
(
entry
->
lcid
,
entry
->
flags
,
entry
->
first
,
entry
->
first_len
,
entry
->
second
,
entry
->
second_len
);
todo_wine_if
(
entry
->
flags
==
LINGUISTIC_IGNOREDIACRITIC
)
{
ok
(
ret
==
entry
->
ret
,
"%d: got %d, expected %d
\n
"
,
i
,
ret
,
entry
->
ret
);
ok
(
GetLastError
()
==
(
ret
?
0xdeadbeef
:
entry
->
le
),
"%d: got last error %d, expected %d
\n
"
,
i
,
GetLastError
(),
(
ret
?
0xdeadbeef
:
entry
->
le
));
}
}
ret
=
CompareStringA
(
lcid
,
NORM_IGNORECASE
,
"Salut"
,
-
1
,
"Salute"
,
-
1
);
...
...
@@ -1879,19 +1895,6 @@ static void test_CompareStringA(void)
ret
=
CompareStringA
(
lcid
,
NORM_IGNORECASE
,
"Salut"
,
5
,
"saLuT"
,
-
1
);
ok
(
ret
==
CSTR_EQUAL
,
"(Salut/saLuT) Expected CSTR_EQUAL, got %d
\n
"
,
ret
);
/* test for CompareStringA flags */
SetLastError
(
0xdeadbeef
);
ret
=
CompareStringA
(
LOCALE_SYSTEM_DEFAULT
,
0x8
,
"NULL"
,
-
1
,
"NULL"
,
-
1
);
ok
(
GetLastError
()
==
ERROR_INVALID_FLAGS
,
"unexpected error code %d
\n
"
,
GetLastError
());
ok
(
!
ret
,
"CompareStringA must fail with invalid flag
\n
"
);
SetLastError
(
0xdeadbeef
);
ret
=
CompareStringA
(
LOCALE_SYSTEM_DEFAULT
,
LOCALE_USE_CP_ACP
,
"NULL"
,
-
1
,
"NULL"
,
-
1
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"unexpected error code %d
\n
"
,
GetLastError
());
ok
(
ret
==
CSTR_EQUAL
,
"CompareStringA error: %d != CSTR_EQUAL
\n
"
,
ret
);
/* end of test for CompareStringA flags */
ret
=
lstrcmpA
(
""
,
""
);
ok
(
ret
==
0
,
"lstrcmpA(
\"\"
,
\"\"
) should return 0, got %d
\n
"
,
ret
);
...
...
@@ -2031,6 +2034,11 @@ static void test_CompareStringW(void)
success
=
VirtualFree
(
buf
,
0
,
MEM_RELEASE
);
ok
(
success
,
"VirtualFree failed with %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
CompareStringW
(
CP_ACP
,
SORT_DIGITSASNUMBERS
,
L"NULL"
,
-
1
,
L"NULL"
,
-
1
);
todo_wine
ok
(
ret
==
CSTR_EQUAL
||
broken
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_FLAGS
)
/* <Win7 */
,
"expected CSTR_EQUAL, got %d, last error %d
\n
"
,
ret
,
GetLastError
());
ret
=
CompareStringW
(
CP_ACP
,
0
,
ABC_EE
,
3
,
ABC_FF
,
3
);
ok
(
ret
==
CSTR_EQUAL
,
"expected CSTR_EQUAL, got %d
\n
"
,
ret
);
ret
=
CompareStringW
(
CP_ACP
,
0
,
ABC_EE
,
5
,
ABC_FF
,
3
);
...
...
dlls/kernelbase/locale.c
View file @
ed61ff43
...
...
@@ -3115,6 +3115,13 @@ INT WINAPI DECLSPEC_HOTPATCH CompareStringA( LCID lcid, DWORD flags, const char
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
if
(
flags
&
SORT_DIGITSASNUMBERS
)
{
SetLastError
(
ERROR_INVALID_FLAGS
);
return
0
;
}
if
(
len1
<
0
)
len1
=
strlen
(
str1
);
if
(
len2
<
0
)
len2
=
strlen
(
str2
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment