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