Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
c2a455a2
Commit
c2a455a2
authored
Jun 01, 2022
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase: Fix checks for valid locale in LCMapStringW/Ex.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
9990dc11
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
40 deletions
+26
-40
locale.c
dlls/kernel32/tests/locale.c
+10
-4
locale.c
dlls/kernelbase/locale.c
+16
-36
No files found.
dlls/kernel32/tests/locale.c
View file @
c2a455a2
...
...
@@ -2669,10 +2669,13 @@ static void test_LCMapStringW(void)
SetLastError
(
0xdeadbeef
);
ret
=
LCMapStringW
((
LCID
)
-
1
,
LCMAP_LOWERCASE
,
upper_case
,
-
1
,
buf
,
ARRAY_SIZE
(
buf
));
todo_wine
{
ok
(
!
ret
,
"LCMapStringW should fail with bad lcid
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"unexpected error code %ld
\n
"
,
GetLastError
());
}
SetLastError
(
0xdeadbeef
);
ret
=
LCMapStringW
((
LCID
)
0xdead
,
LCMAP_HIRAGANA
,
upper_case
,
-
1
,
buf
,
ARRAY_SIZE
(
buf
));
ok
(
!
ret
,
"LCMapStringW should fail with bad lcid
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"unexpected error code %ld
\n
"
,
GetLastError
());
test_lcmapstring_unicode
(
LCMapStringW_wrapper
,
"LCMapStringW:"
);
}
...
...
@@ -2698,10 +2701,13 @@ static void test_LCMapStringEx(void)
SetLastError
(
0xdeadbeef
);
ret
=
pLCMapStringEx
(
invalidW
,
LCMAP_LOWERCASE
,
upper_case
,
-
1
,
buf
,
ARRAY_SIZE
(
buf
),
NULL
,
NULL
,
0
);
todo_wine
{
ok
(
!
ret
,
"LCMapStringEx should fail with bad locale name
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"unexpected error code %ld
\n
"
,
GetLastError
());
}
SetLastError
(
0xdeadbeef
);
ret
=
pLCMapStringEx
(
invalidW
,
LCMAP_HIRAGANA
,
upper_case
,
-
1
,
buf
,
ARRAY_SIZE
(
buf
),
NULL
,
NULL
,
0
);
ok
(
ret
,
"LCMapStringEx should not fail with bad locale name
\n
"
);
/* test reserved parameters */
ret
=
pLCMapStringEx
(
LOCALE_NAME_USER_DEFAULT
,
LCMAP_LOWERCASE
,
...
...
dlls/kernelbase/locale.c
View file @
c2a455a2
...
...
@@ -672,7 +672,12 @@ static const struct sortguid *get_language_sort( const WCHAR *name )
name
=
locale_strings
+
user_locale
->
sname
+
1
;
}
if
(
!
(
entry
=
find_lcname_entry
(
name
)))
return
NULL
;
if
(
!
(
entry
=
find_lcname_entry
(
name
)))
{
WARN
(
"unknown locale %s
\n
"
,
debugstr_w
(
name
)
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
NULL
;
}
if
((
ret
=
locale_sorts
[
entry
-
lcnames_index
]))
return
ret
;
lcid
=
entry
->
id
;
...
...
@@ -686,22 +691,17 @@ static const struct sortguid *get_language_sort( const WCHAR *name )
if
(
!
RegQueryValueExW
(
key
,
name
,
NULL
,
&
type
,
(
BYTE
*
)
guidstr
,
&
size
)
&&
type
==
REG_SZ
)
{
RtlInitUnicodeString
(
&
str
,
guidstr
);
if
(
!
RtlGUIDFromString
(
&
str
,
&
guid
))
{
ret
=
find_sortguid
(
&
guid
);
goto
done
;
}
if
(
!
RtlGUIDFromString
(
&
str
,
&
guid
))
ret
=
find_sortguid
(
&
guid
);
break
;
}
if
(
!
name
[
0
])
break
;
name
=
locale_strings
+
(
SORTIDFROMLCID
(
lcid
)
?
locale
->
sname
:
locale
->
sparent
)
+
1
;
if
(
!
(
locale
=
get_locale_by_name
(
name
,
&
lcid
)))
break
;
}
}
ret
=
&
sort
.
guids
[
0
];
done:
RegCloseKey
(
key
);
if
(
ret
)
locale_sorts
[
entry
-
lcnames_index
]
=
ret
;
}
if
(
!
ret
)
ret
=
&
sort
.
guids
[
0
];
locale_sorts
[
entry
-
lcnames_index
]
=
ret
;
return
ret
;
}
...
...
@@ -4484,12 +4484,7 @@ INT WINAPI CompareStringEx( const WCHAR *locale, DWORD flags, const WCHAR *str1,
return
0
;
}
if
(
!
(
sortid
=
get_language_sort
(
locale
)))
{
FIXME
(
"unknown locale %s
\n
"
,
debugstr_w
(
locale
)
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
if
(
!
(
sortid
=
get_language_sort
(
locale
)))
return
0
;
if
(
!
str1
||
!
str2
)
{
...
...
@@ -4971,12 +4966,7 @@ INT WINAPI DECLSPEC_HOTPATCH FindNLSStringEx( const WCHAR *locale, DWORD flags,
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
-
1
;
}
if
(
!
(
sortid
=
get_language_sort
(
locale
)))
{
WARN
(
"unknown locale %s
\n
"
,
debugstr_w
(
locale
)
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
-
1
;
}
if
(
!
(
sortid
=
get_language_sort
(
locale
)))
return
-
1
;
if
(
srclen
==
-
1
)
srclen
=
lstrlenW
(
src
);
if
(
valuelen
==
-
1
)
valuelen
=
lstrlenW
(
value
);
...
...
@@ -5634,11 +5624,8 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetNLSVersionEx( NLS_FUNCTION func, const WCHAR *l
SetLastError
(
ERROR_INSUFFICIENT_BUFFER
);
return
FALSE
;
}
if
(
!
(
sortid
=
get_language_sort
(
locale
)))
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
if
(
!
(
sortid
=
get_language_sort
(
locale
)))
return
FALSE
;
info
->
dwNLSVersion
=
info
->
dwDefinedVersion
=
sort
.
version
;
if
(
info
->
dwNLSVersionInfoSize
>=
sizeof
(
*
info
))
...
...
@@ -6329,13 +6316,10 @@ INT WINAPI DECLSPEC_HOTPATCH LCMapStringEx( const WCHAR *locale, DWORD flags, co
if
(
!
dstlen
)
dst
=
NULL
;
if
(
flags
&
(
LCMAP_L
INGUISTIC_CASING
|
LCMAP_SORTKEY
)
&&
!
(
sortid
=
get_language_sort
(
locale
)
))
if
(
flags
&
(
LCMAP_L
OWERCASE
|
LCMAP_UPPERCASE
|
LCMAP_SORTKEY
))
{
FIXME
(
"unknown locale %s
\n
"
,
debugstr_w
(
locale
)
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
if
(
!
(
sortid
=
get_language_sort
(
locale
)))
return
0
;
}
if
(
flags
&
LCMAP_SORTKEY
)
{
if
(
src
==
dst
)
...
...
@@ -6574,9 +6558,6 @@ INT WINAPI DECLSPEC_HOTPATCH LCMapStringW( LCID lcid, DWORD flags, const WCHAR *
WCHAR
*
dst
,
int
dstlen
)
{
const
WCHAR
*
locale
=
LOCALE_NAME_USER_DEFAULT
;
if
(
flags
&
(
LCMAP_LINGUISTIC_CASING
|
LCMAP_SORTKEY
))
{
const
NLS_LOCALE_LCID_INDEX
*
entry
;
switch
(
lcid
)
...
...
@@ -6599,7 +6580,6 @@ INT WINAPI DECLSPEC_HOTPATCH LCMapStringW( LCID lcid, DWORD flags, const WCHAR *
locale
=
locale_strings
+
entry
->
name
+
1
;
break
;
}
}
return
LCMapStringEx
(
locale
,
flags
,
src
,
srclen
,
dst
,
dstlen
,
NULL
,
NULL
,
0
);
}
...
...
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