Author: fireball
Date: Sun Mar 6 11:00:17 2011
New Revision: 50981
URL: http://svn.reactos.org/svn/reactos?rev=50981&view=rev
Log:
[NTOS/FSRTL]
- Implement parameters checking in FsRtlIsNameInExpressionPrivate.
- Add two shortcuts for common wildcard invocations to make the function faster.
- Second (main part of the function) is still under review.
Modified:
trunk/reactos/ntoskrnl/fsrtl/name.c
Modified: trunk/reactos/ntoskrnl/fsrtl/name.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fsrtl/name.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/fsrtl/name.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/fsrtl/name.c [iso-8859-1] Sun Mar 6 11:00:17 2011
@@ -5,7 +5,8 @@
* PURPOSE: Provides name parsing and other support routines for FSDs
* PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org)
* Filip Navara (navaraf(a)reactos.org)
- * Pierre Schweitzer (pierre.schweitzer(a)reactos.org)
+ * Pierre Schweitzer (pierre.schweitzer(a)reactos.org)
+ * Aleksey Bragin (aleksey(a)reactos.org)
*/
/* INCLUDES ******************************************************************/
@@ -23,9 +24,78 @@
IN PWCHAR UpcaseTable OPTIONAL)
{
USHORT ExpressionPosition = 0, NamePosition = 0, MatchingChars, StarFound = MAXUSHORT;
+ UNICODE_STRING IntExpression;
PAGED_CODE();
+ /* Check if we were given strings at all */
+ if (!Name->Length || !Expression->Length)
+ {
+ /* Return TRUE if both strings are empty, otherwise FALSE */
+ if (Name->Length == 0 && Expression->Length == 0)
+ return TRUE;
+ else
+ return FALSE;
+ }
+
+ /* Check for a shortcut: just one wildcard */
+ if (Expression->Length == 2)
+ {
+ if (Expression->Buffer[0] == L'*')
+ return TRUE;
+ }
+
ASSERT(!IgnoreCase || UpcaseTable);
+
+ /* Another shortcut, wildcard followed by some string */
+ if (Expression->Buffer[0] == L'*')
+ {
+ /* Copy Expression to our local variable */
+ IntExpression = *Expression;
+
+ /* Skip the first char */
+ IntExpression.Buffer++;
+ IntExpression.Length -= sizeof(WCHAR);
+
+ /* Continue only if the rest of the expression does NOT contain
+ any more wildcards */
+ if (!FsRtlDoesNameContainWildCards(&IntExpression))
+ {
+ /* Check for a degenerate case */
+ if (Name->Length < (Expression->Length - sizeof(WCHAR)))
+ return FALSE;
+
+ /* Calculate position */
+ NamePosition = (Name->Length - IntExpression.Length) / sizeof(WCHAR);
+
+ /* Compare */
+ if (!IgnoreCase)
+ {
+ /* We can just do a byte compare */
+ return RtlEqualMemory(IntExpression.Buffer,
+ Name->Buffer + NamePosition,
+ IntExpression.Length);
+ }
+ else
+ {
+ /* Not so easy, need to upcase and check char by char */
+ for (ExpressionPosition = 0; ExpressionPosition < (IntExpression.Length / sizeof(WCHAR)); ExpressionPosition++)
+ {
+ /* Assert that expression is already upcased! */
+ ASSERT(IntExpression.Buffer[ExpressionPosition] == UpcaseTable[IntExpression.Buffer[ExpressionPosition]]);
+
+ /* Now compare upcased name char with expression */
+ if (UpcaseTable[Name->Buffer[NamePosition + ExpressionPosition]] !=
+ UpcaseTable[IntExpression.Buffer[ExpressionPosition]])
+ {
+ return FALSE;
+ }
+ }
+
+ /* It matches */
+ return TRUE;
+ }
+ }
+ }
while (NamePosition < Name->Length / sizeof(WCHAR) && ExpressionPosition < Expression->Length / sizeof(WCHAR))
{
@@ -385,7 +455,7 @@
if (IgnoreCase && !UpcaseTable)
{
Status = RtlUpcaseUnicodeString(&IntName, Name, TRUE);
- if (Status != STATUS_SUCCESS)
+ if (!NT_SUCCESS(Status))
{
ExRaiseStatus(Status);
}
Author: rmessiant
Date: Sun Mar 6 00:37:10 2011
New Revision: 50978
URL: http://svn.reactos.org/svn/reactos?rev=50978&view=rev
Log:
[HEAP]
- RtlpInsertUnCommittedPages: Don't rely on linked list data in an UCR Descriptor after destroying it.
No functionality change because the linked list data was still "as expected", but not something we want to rely on.
- RtlpCreateUnCommittedRange: Fix a typo that caused the head of UCR Segment list of the Heap to be treated as an UCR Segment header.
Side effects of the typo: When this list wasn't empty, the (fake) UCR Segment it described was grown to contain more UCR descriptors.
Due to the data involved, this always happened to be the initial Heap Segment, which contains the Heap Header.
Writing the new UCR descriptors caused the Heap Header and trailing Heap Entries to be partially corrupted.
Modified:
trunk/reactos/lib/rtl/heap.c
Modified: trunk/reactos/lib/rtl/heap.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heap.c?rev=50978&r…
==============================================================================
--- trunk/reactos/lib/rtl/heap.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/heap.c [iso-8859-1] Sun Mar 6 00:37:10 2011
@@ -414,7 +414,7 @@
if (IsListEmpty(&Heap->UCRList))
{
/* Get a pointer to the first UCR segment */
- UcrSegment = CONTAINING_RECORD(&Heap->UCRSegments.Flink, HEAP_UCR_SEGMENT, ListEntry);
+ UcrSegment = CONTAINING_RECORD(Heap->UCRSegments.Flink, HEAP_UCR_SEGMENT, ListEntry);
/* Check the list of UCR segments */
if (IsListEmpty(&Heap->UCRSegments) ||
@@ -539,8 +539,11 @@
Address = (ULONG_PTR)UcrDescriptor->Address;
Size += UcrDescriptor->Size;
- /* Remove it from the list and destroy it */
- RemoveEntryList(Current);
+ /* Advance to the next descriptor */
+ Current = Current->Flink;
+
+ /* Remove the current descriptor from the list and destroy it */
+ RemoveEntryList(&UcrDescriptor->SegmentEntry);
RtlpDestroyUnCommittedRange(Segment, UcrDescriptor);
Segment->NumberOfUnCommittedRanges--;