From 127fa1afc6c7fa6a264ce0eb442e8a7523a8327f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Thu, 2 Jan 2020 21:10:42 +0100 Subject: [PATCH] [RTL] Fix RtlValidateUnicodeString() regarding the tests and add some SAL annotations. --- sdk/lib/rtl/unicode.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/sdk/lib/rtl/unicode.c b/sdk/lib/rtl/unicode.c index 7d2470a9591..7f045401326 100644 --- a/sdk/lib/rtl/unicode.c +++ b/sdk/lib/rtl/unicode.c @@ -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