Author: cgutman
Date: Wed Jul 20 17:59:16 2011
New Revision: 52744
URL:
http://svn.reactos.org/svn/reactos?rev=52744&view=rev
Log:
[RTL]
- Validate parameters passed into path functions
Modified:
trunk/reactos/lib/rtl/path.c
Modified: trunk/reactos/lib/rtl/path.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/path.c?rev=52744&a…
==============================================================================
--- trunk/reactos/lib/rtl/path.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/path.c [iso-8859-1] Wed Jul 20 17:59:16 2011
@@ -51,6 +51,9 @@
USHORT ReturnOffset = 0, ReturnLength;
WCHAR c;
+ /* Validate the input */
+ if (!PathString) return 0;
+
/* Check what type of path this is */
switch (RtlDetermineDosPathNameType_Ustr(PathString))
{
@@ -198,8 +201,14 @@
NTAPI
RtlDetermineDosPathNameType_Ustr(IN PCUNICODE_STRING PathString)
{
- PWCHAR Path = PathString->Buffer;
- ULONG Chars = PathString->Length / sizeof(WCHAR);
+ PWCHAR Path;
+ ULONG Chars;
+
+ /* Validate the input */
+ if (!PathString) return RtlPathTypeUnknown;
+
+ Path = PathString->Buffer;
+ Chars = PathString->Length / sizeof(WCHAR);
/*
* The algorithm is similar to RtlDetermineDosPathNameType_U but here we
@@ -282,7 +291,7 @@
/* Handle initial path type and failure case */
*PathType = RtlPathTypeUnknown;
- if (!(Size) || (FileName->Buffer[0] == UNICODE_NULL)) return 0;
+ if (!(Size) || !(Buffer) || !(FileName) || (FileName->Buffer[0] == UNICODE_NULL))
return 0;
/* Break filename into component parts */
FileNameBuffer = FileName->Buffer;
@@ -358,12 +367,15 @@
NTSTATUS
NTAPI
RtlpWin32NTNameToNtPathName_U(IN PUNICODE_STRING DosPath,
- IN PUNICODE_STRING NtPath,
+ OUT PUNICODE_STRING NtPath,
OUT PCWSTR *PartName,
OUT PRTL_RELATIVE_NAME_U RelativeName)
{
ULONG DosLength;
PWSTR NewBuffer, p;
+
+ /* Validate the input */
+ if (!DosPath) return STATUS_OBJECT_NAME_INVALID;
/* Validate the DOS length */
DosLength = DosPath->Length;
@@ -444,6 +456,9 @@
DPRINT("Relative: %lx DosName: %wZ NtName: %wZ, PartName: %p, RelativeName:
%p\n",
HaveRelative, DosName, NtName, PartName, RelativeName);
MaxLength = sizeof(BigBuffer);
+
+ /* Validate the input */
+ if (!DosName) return STATUS_OBJECT_NAME_INVALID;
/* Capture input string */
CapturedDosName = *DosName;
@@ -670,6 +685,9 @@
NTSTATUS Status;
FILE_BASIC_INFORMATION BasicInformation;
+ /* Validate the input */
+ if (!FileName) return FALSE;
+
/* Get the NT Path */
Result = RtlDosPathNameToRelativeNtPathName_Ustr(FileName,
&NtPathName,
@@ -798,7 +816,9 @@
RtlDetermineDosPathNameType_U(IN PCWSTR Path)
{
DPRINT("RtlDetermineDosPathNameType_U %S\n", Path);
- ASSERT(Path != NULL);
+
+ /* Validate the input */
+ if (!Path) return RtlPathTypeUnknown;
/* Unlike the newer RtlDetermineDosPathNameType_U we assume 4 characters */
if (IS_PATH_SEPARATOR(Path[0]))
@@ -1443,6 +1463,9 @@
PWCHAR NewBuffer, BufferStart;
PCWSTR p;
+ /* Validate the input */
+ if (!(Path) || !(FileName)) return 0;
+
/* Check if this is an absolute path */
if (RtlDetermineDosPathNameType_U(FileName) != RtlPathTypeRelative)
{