mirror of
https://github.com/reactos/reactos.git
synced 2025-05-30 06:28:34 +00:00
[KERNEL32]
- npipe.c: * Use RtlPrefixUnicodeString instead of RtlPrefixString with casts. * Check results of RtlCreateUnicodeString and RtlPrefixUnicodeString, return FALSE if they fail and set an appropriate last error. * Free the string created with RtlCreateUnicodeString instead of leaking memory. * Fix a path type check (RtlPathTypeUncAbsolute instead of RtlPathTypeRootLocalDevice). - path.c: I prefer seeing the default case at the end of the switch (no functional changes). [NTOS:MM] - Use RtlPrefixUnicodeString instead of RtlPrefixString with casts. [RTL] - RtlPrefixString acts on general PSTRINGs (which are not UNICODE). - Remove extra spaces between names of functions and parentheses. - Clarify the fact that we run over characters. svn path=/trunk/; revision=60085
This commit is contained in:
parent
02d7889f97
commit
6e8c79e64d
5 changed files with 50 additions and 33 deletions
|
@ -382,7 +382,11 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
|
|
||||||
/* Start by making a unicode string of the name */
|
/* Start by making a unicode string of the name */
|
||||||
TRACE("Sent path: %S\n", lpNamedPipeName);
|
TRACE("Sent path: %S\n", lpNamedPipeName);
|
||||||
RtlCreateUnicodeString(&NamedPipeName, lpNamedPipeName);
|
if (!RtlCreateUnicodeString(&NamedPipeName, lpNamedPipeName))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
NameLength = NamedPipeName.Length / sizeof(WCHAR);
|
NameLength = NamedPipeName.Length / sizeof(WCHAR);
|
||||||
|
|
||||||
/* All slashes must become backslashes */
|
/* All slashes must become backslashes */
|
||||||
|
@ -401,7 +405,14 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
{
|
{
|
||||||
/* Make sure it's a valid prefix */
|
/* Make sure it's a valid prefix */
|
||||||
RtlInitUnicodeString(&PipePrefix, L"\\\\.\\pipe\\");
|
RtlInitUnicodeString(&PipePrefix, L"\\\\.\\pipe\\");
|
||||||
RtlPrefixString((PANSI_STRING)&PipePrefix, (PANSI_STRING)&NewName, TRUE);
|
if (!RtlPrefixUnicodeString(&PipePrefix, &NewName, TRUE))
|
||||||
|
{
|
||||||
|
/* The name is invalid */
|
||||||
|
WARN("Invalid name!\n");
|
||||||
|
RtlFreeUnicodeString(&NamedPipeName);
|
||||||
|
BaseSetLastNTError(STATUS_OBJECT_PATH_SYNTAX_BAD);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Move past it */
|
/* Move past it */
|
||||||
NewName.Buffer += 9;
|
NewName.Buffer += 9;
|
||||||
|
@ -411,7 +422,7 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
TRACE("NewName: %wZ\n", &NewName);
|
TRACE("NewName: %wZ\n", &NewName);
|
||||||
RtlInitUnicodeString(&DevicePath, L"\\DosDevices\\pipe\\");
|
RtlInitUnicodeString(&DevicePath, L"\\DosDevices\\pipe\\");
|
||||||
}
|
}
|
||||||
else if (Type == RtlPathTypeRootLocalDevice)
|
else if (Type == RtlPathTypeUncAbsolute)
|
||||||
{
|
{
|
||||||
/* The path is \\server\\pipe\name; find the pipename itself */
|
/* The path is \\server\\pipe\name; find the pipename itself */
|
||||||
p = &NewName.Buffer[2];
|
p = &NewName.Buffer[2];
|
||||||
|
@ -436,6 +447,7 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
{
|
{
|
||||||
/* The name is invalid */
|
/* The name is invalid */
|
||||||
WARN("Invalid name!\n");
|
WARN("Invalid name!\n");
|
||||||
|
RtlFreeUnicodeString(&NamedPipeName);
|
||||||
BaseSetLastNTError(STATUS_OBJECT_PATH_SYNTAX_BAD);
|
BaseSetLastNTError(STATUS_OBJECT_PATH_SYNTAX_BAD);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -445,6 +457,7 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WARN("Invalid path type\n");
|
WARN("Invalid path type\n");
|
||||||
|
RtlFreeUnicodeString(&NamedPipeName);
|
||||||
BaseSetLastNTError(STATUS_OBJECT_PATH_SYNTAX_BAD);
|
BaseSetLastNTError(STATUS_OBJECT_PATH_SYNTAX_BAD);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -455,6 +468,7 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
WaitPipeInfo = RtlAllocateHeap(RtlGetProcessHeap(), 0, WaitPipeInfoSize);
|
WaitPipeInfo = RtlAllocateHeap(RtlGetProcessHeap(), 0, WaitPipeInfoSize);
|
||||||
if (WaitPipeInfo == NULL)
|
if (WaitPipeInfo == NULL)
|
||||||
{
|
{
|
||||||
|
RtlFreeUnicodeString(&NamedPipeName);
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -478,9 +492,9 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
{
|
{
|
||||||
/* Fail; couldn't open */
|
/* Fail; couldn't open */
|
||||||
WARN("Status: %lx\n", Status);
|
WARN("Status: %lx\n", Status);
|
||||||
BaseSetLastNTError(Status);
|
|
||||||
RtlFreeUnicodeString(&NamedPipeName);
|
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, WaitPipeInfo);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, WaitPipeInfo);
|
||||||
|
RtlFreeUnicodeString(&NamedPipeName);
|
||||||
|
BaseSetLastNTError(Status);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,7 +551,7 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
{
|
{
|
||||||
/* Failure to wait on the pipe */
|
/* Failure to wait on the pipe */
|
||||||
WARN("Status: %lx\n", Status);
|
WARN("Status: %lx\n", Status);
|
||||||
BaseSetLastNTError (Status);
|
BaseSetLastNTError(Status);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -740,6 +740,19 @@ SkipPathTypeIndicator_U(IN LPWSTR Path)
|
||||||
/* Check what kind of path this is and how many slashes to skip */
|
/* Check what kind of path this is and how many slashes to skip */
|
||||||
switch (RtlDetermineDosPathNameType_U(Path))
|
switch (RtlDetermineDosPathNameType_U(Path))
|
||||||
{
|
{
|
||||||
|
case RtlPathTypeUncAbsolute:
|
||||||
|
case RtlPathTypeLocalDevice:
|
||||||
|
{
|
||||||
|
/* Keep going until we bypass the path indicators */
|
||||||
|
for (ReturnPath = Path + 2, i = 2; (i > 0) && (*ReturnPath); ReturnPath++)
|
||||||
|
{
|
||||||
|
/* We look for 2 slashes, so keep at it until we find them */
|
||||||
|
if ((*ReturnPath == L'\\') || (*ReturnPath == L'/')) i--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReturnPath;
|
||||||
|
}
|
||||||
|
|
||||||
case RtlPathTypeDriveAbsolute:
|
case RtlPathTypeDriveAbsolute:
|
||||||
return Path + 3;
|
return Path + 3;
|
||||||
|
|
||||||
|
@ -755,18 +768,6 @@ SkipPathTypeIndicator_U(IN LPWSTR Path)
|
||||||
case RtlPathTypeRootLocalDevice:
|
case RtlPathTypeRootLocalDevice:
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
case RtlPathTypeUncAbsolute:
|
|
||||||
case RtlPathTypeLocalDevice:
|
|
||||||
|
|
||||||
/* Keep going until we bypass the path indicators */
|
|
||||||
for (ReturnPath = Path + 2, i = 2; (i > 0) && (*ReturnPath); ReturnPath++)
|
|
||||||
{
|
|
||||||
/* We look for 2 slashes, so keep at it until we find them */
|
|
||||||
if ((*ReturnPath == L'\\') || (*ReturnPath == L'/')) i--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ReturnPath;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2165,8 +2165,8 @@ NTSYSAPI
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlPrefixString(
|
RtlPrefixString(
|
||||||
PCANSI_STRING String1,
|
PSTRING String1,
|
||||||
PCANSI_STRING String2,
|
PSTRING String2,
|
||||||
BOOLEAN CaseInsensitive
|
BOOLEAN CaseInsensitive
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -835,17 +835,18 @@ RtlInt64ToUnicodeString (
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlPrefixString(
|
RtlPrefixString(
|
||||||
PANSI_STRING String1,
|
PSTRING String1,
|
||||||
PANSI_STRING String2,
|
PSTRING String2,
|
||||||
BOOLEAN CaseInsensitive)
|
BOOLEAN CaseInsensitive)
|
||||||
{
|
{
|
||||||
PCHAR pc1;
|
PCHAR pc1;
|
||||||
PCHAR pc2;
|
PCHAR pc2;
|
||||||
ULONG Length;
|
ULONG NumChars;
|
||||||
|
|
||||||
if (String2->Length < String1->Length) return FALSE;
|
if (String2->Length < String1->Length)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
Length = String1->Length;
|
NumChars = String1->Length;
|
||||||
pc1 = String1->Buffer;
|
pc1 = String1->Buffer;
|
||||||
pc2 = String2->Buffer;
|
pc2 = String2->Buffer;
|
||||||
|
|
||||||
|
@ -853,15 +854,15 @@ RtlPrefixString(
|
||||||
{
|
{
|
||||||
if (CaseInsensitive)
|
if (CaseInsensitive)
|
||||||
{
|
{
|
||||||
while (Length--)
|
while (NumChars--)
|
||||||
{
|
{
|
||||||
if (RtlUpperChar (*pc1++) != RtlUpperChar (*pc2++))
|
if (RtlUpperChar(*pc1++) != RtlUpperChar(*pc2++))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (Length--)
|
while (NumChars--)
|
||||||
{
|
{
|
||||||
if (*pc1++ != *pc2++)
|
if (*pc1++ != *pc2++)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -923,6 +924,7 @@ RtlPrefixUnicodeString(
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -827,8 +827,8 @@ MiSnapThunk(IN PVOID DllBase,
|
||||||
InLoadOrderLinks);
|
InLoadOrderLinks);
|
||||||
|
|
||||||
/* Check if it matches */
|
/* Check if it matches */
|
||||||
if (RtlPrefixString((PSTRING)&ForwarderName,
|
if (RtlPrefixUnicodeString(&ForwarderName,
|
||||||
(PSTRING)&LdrEntry->BaseDllName,
|
&LdrEntry->BaseDllName,
|
||||||
TRUE))
|
TRUE))
|
||||||
{
|
{
|
||||||
/* Get the forwarder export directory */
|
/* Get the forwarder export directory */
|
||||||
|
|
Loading…
Reference in a new issue