Misc addendum to CORE-14271 (#1529)

* [ADVAPI32] Simplify RtlCreateUnicodeStringFromAsciiz() return value check

RtlCreateUnicodeStringFromAsciiz() returns a BOOLEAN, not a BOOL.

No functional change.

Addendum to
CORE-14271

* [USER32] Simplify RtlCreateUnicodeStringFromAsciiz() return value check

RtlCreateUnicodeStringFromAsciiz() returns a BOOLEAN, not a UINT.

Also, add a FIXME.

No functional change.

Addendum to
CORE-14271

* [USER32] Simplify RegisterClipboardFormatA/W() a bit

No functional change.

* [UDFS] Simplify SeSinglePrivilegeCheck() return value check

No functional change.

Addendum to
CORE-14271
This commit is contained in:
Serge Gautherie 2019-06-04 16:56:33 +02:00 committed by Hermès BÉLUSCA - MAÏTO
parent 77ac92d817
commit 38db074491
3 changed files with 15 additions and 21 deletions

View file

@ -4847,10 +4847,7 @@ RegSetValueExA(HKEY hKey,
/* Convert SubKey name to Unicode */ /* Convert SubKey name to Unicode */
if (lpValueName != NULL && lpValueName[0] != '\0') if (lpValueName != NULL && lpValueName[0] != '\0')
{ {
BOOL bConverted; if (!RtlCreateUnicodeStringFromAsciiz(&ValueName, (PSTR)lpValueName))
bConverted = RtlCreateUnicodeStringFromAsciiz(&ValueName,
(PSTR)lpValueName);
if(!bConverted)
return ERROR_NOT_ENOUGH_MEMORY; return ERROR_NOT_ENOUGH_MEMORY;
} }
else else

View file

@ -934,9 +934,9 @@ UDFCheckAccessRights(
) )
{ {
NTSTATUS RC; NTSTATUS RC;
BOOLEAN SecurityCheck = TRUE;
BOOLEAN ROCheck = FALSE; BOOLEAN ROCheck = FALSE;
#ifdef UDF_ENABLE_SECURITY #ifdef UDF_ENABLE_SECURITY
BOOLEAN SecurityCheck;
PSECURITY_DESCRIPTOR SecDesc; PSECURITY_DESCRIPTOR SecDesc;
SECURITY_SUBJECT_CONTEXT SubjectContext; SECURITY_SUBJECT_CONTEXT SubjectContext;
ACCESS_MASK LocalAccessMask; ACCESS_MASK LocalAccessMask;
@ -1011,8 +1011,7 @@ treat_as_ro:
} else } else
#endif //UDF_ENABLE_SECURITY #endif //UDF_ENABLE_SECURITY
if(DesiredAccess & ACCESS_SYSTEM_SECURITY) { if(DesiredAccess & ACCESS_SYSTEM_SECURITY) {
SecurityCheck = SeSinglePrivilegeCheck(SeExports->SeSecurityPrivilege, UserMode); if (!SeSinglePrivilegeCheck(SeExports->SeSecurityPrivilege, UserMode))
if(!SecurityCheck)
return STATUS_ACCESS_DENIED; return STATUS_ACCESS_DENIED;
Ccb->PreviouslyGrantedAccess |= ACCESS_SYSTEM_SECURITY; Ccb->PreviouslyGrantedAccess |= ACCESS_SYSTEM_SECURITY;
} }

View file

@ -71,7 +71,7 @@ GetClipboardFormatNameA(UINT format,
/* clear result string */ /* clear result string */
Length = 0; Length = 0;
} }
lpszFormatName[Length] = '\0'; lpszFormatName[Length] = ANSI_NULL;
} }
RtlFreeHeap(RtlGetProcessHeap(), 0, lpBuffer); RtlFreeHeap(RtlGetProcessHeap(), 0, lpBuffer);
@ -97,7 +97,7 @@ UINT
WINAPI WINAPI
RegisterClipboardFormatA(LPCSTR lpszFormat) RegisterClipboardFormatA(LPCSTR lpszFormat)
{ {
UINT ret = 0; UINT ret;
UNICODE_STRING usFormat = {0}; UNICODE_STRING usFormat = {0};
if (lpszFormat == NULL) if (lpszFormat == NULL)
@ -106,20 +106,22 @@ RegisterClipboardFormatA(LPCSTR lpszFormat)
return 0; return 0;
} }
/* check for "" */ if (*lpszFormat == ANSI_NULL)
if (*lpszFormat == 0) //NULL
{ {
SetLastError(ERROR_INVALID_NAME); SetLastError(ERROR_INVALID_NAME);
return 0; return 0;
} }
ret = RtlCreateUnicodeStringFromAsciiz(&usFormat, lpszFormat); if (!RtlCreateUnicodeStringFromAsciiz(&usFormat, lpszFormat))
if (ret)
{ {
ret = NtUserRegisterWindowMessage(&usFormat); //(LPCWSTR) // FIXME: Shouldn't we 'SetLastError(ERROR_NOT_ENOUGH_MEMORY);'?
RtlFreeUnicodeString(&usFormat); return 0;
} }
ret = NtUserRegisterWindowMessage(&usFormat); //(LPCWSTR)
RtlFreeUnicodeString(&usFormat);
return ret; return ret;
} }
@ -130,7 +132,6 @@ UINT
WINAPI WINAPI
RegisterClipboardFormatW(LPCWSTR lpszFormat) RegisterClipboardFormatW(LPCWSTR lpszFormat)
{ {
UINT ret = 0;
UNICODE_STRING usFormat = {0}; UNICODE_STRING usFormat = {0};
if (lpszFormat == NULL) if (lpszFormat == NULL)
@ -139,17 +140,14 @@ RegisterClipboardFormatW(LPCWSTR lpszFormat)
return 0; return 0;
} }
/* check for "" */ if (*lpszFormat == UNICODE_NULL)
if (*lpszFormat == 0) //NULL
{ {
SetLastError(ERROR_INVALID_NAME); SetLastError(ERROR_INVALID_NAME);
return 0; return 0;
} }
RtlInitUnicodeString(&usFormat, lpszFormat); RtlInitUnicodeString(&usFormat, lpszFormat);
ret = NtUserRegisterWindowMessage(&usFormat); return NtUserRegisterWindowMessage(&usFormat);
return ret;
} }
static PVOID WINAPI static PVOID WINAPI