[RTL] Fix RtlValidateUnicodeString() regarding the tests and add some SAL annotations.

This commit is contained in:
Hermès Bélusca-Maïto 2020-01-02 21:10:42 +01:00
parent ae8c9a1fa2
commit 127fa1afc6
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -2541,22 +2541,24 @@ RtlDuplicateUnicodeString(
*/ */
NTSTATUS NTSTATUS
NTAPI NTAPI
RtlValidateUnicodeString(IN ULONG Flags, RtlValidateUnicodeString(
IN PCUNICODE_STRING UnicodeString) _In_ ULONG Flags,
_In_ PCUNICODE_STRING String)
{ {
/* currently no flags are supported! */ /* In Windows <= 2003 no flags are supported yet! */
ASSERT(Flags == 0); if (Flags != 0)
return STATUS_INVALID_PARAMETER;
if ((Flags == 0) && /* NOTE: a NULL Unicode string pointer is considered to be a valid one! */
((UnicodeString == NULL) || if (String == NULL)
((UnicodeString->Length != 0) && {
(UnicodeString->Buffer != NULL) && return STATUS_SUCCESS;
((UnicodeString->Length % sizeof(WCHAR)) == 0) && }
((UnicodeString->MaximumLength % sizeof(WCHAR)) == 0) && else if (!((String->Buffer == NULL) && (String->Length != 0 || String->MaximumLength != 0)) &&
(UnicodeString->MaximumLength >= UnicodeString->Length)))) (String->Length % sizeof(WCHAR) == 0) &&
(String->MaximumLength % sizeof(WCHAR) == 0) &&
(String->Length <= String->MaximumLength))
{ {
/* a NULL pointer as a unicode string is considered to be a valid unicode
string! */
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
else else