Author: tfaber
Date: Fri Mar 27 18:09:51 2015
New Revision: 66923
URL:
http://svn.reactos.org/svn/reactos?rev=66923&view=rev
Log:
[CDFS]
- Simplify string handling, add a few asserts
Modified:
trunk/reactos/drivers/filesystems/cdfs/fcb.c
trunk/reactos/drivers/filesystems/cdfs/misc.c
Modified: trunk/reactos/drivers/filesystems/cdfs/fcb.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/f…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/fcb.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/fcb.c [iso-8859-1] Fri Mar 27 18:09:51 2015
@@ -564,16 +564,16 @@
DPRINT ("Offset %lu\n", Offset);
RtlInitUnicodeString(&LongName, Name);
- ShortName.Length = 0;
- ShortName.MaximumLength = 26;
- ShortName.Buffer = ShortNameBuffer;
- memset(ShortNameBuffer, 0, 26);
+ RtlInitEmptyUnicodeString(&ShortName, ShortNameBuffer,
sizeof(ShortNameBuffer));
+ RtlZeroMemory(ShortNameBuffer, sizeof(ShortNameBuffer));
OffsetOfEntry.QuadPart = StreamOffset.QuadPart + Offset;
CdfsShortNameCacheGet(DirectoryFcb, &OffsetOfEntry, &LongName,
&ShortName);
DPRINT("ShortName '%wZ'\n", &ShortName);
+ ASSERT(LongName.Length >= sizeof(WCHAR));
+ ASSERT(ShortName.Length >= sizeof(WCHAR));
if (FsRtlIsNameInExpression(&FileToFindUpcase, &LongName, TRUE, NULL) ||
FsRtlIsNameInExpression(&FileToFindUpcase, &ShortName, TRUE, NULL))
{
Modified: trunk/reactos/drivers/filesystems/cdfs/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/m…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/misc.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/misc.c [iso-8859-1] Fri Mar 27 18:09:51 2015
@@ -108,6 +108,7 @@
return FALSE;
}
+ ASSERT(FileName.Length >= sizeof(WCHAR));
for (i = 0; i < FileName.Length / sizeof(WCHAR) ; i++)
{
/* Don't allow spaces in FileName */
@@ -122,11 +123,10 @@
}
/* Finally, convert the string to call the FsRtl function */
- DbcsName.MaximumLength = 12;
- DbcsName.Buffer = DbcsNameBuffer;
+ RtlInitEmptyAnsiString(&DbcsName, DbcsNameBuffer, sizeof(DbcsNameBuffer));
if (!NT_SUCCESS(RtlUnicodeStringToCountedOemString(&DbcsName,
&FileName,
- FALSE )))
+ FALSE)))
{
return FALSE;
@@ -159,10 +159,7 @@
if (ShortNameEntry->StreamOffset.QuadPart == StreamOffset->QuadPart)
{
/* Cache hit */
- RtlCopyMemory
- (ShortName->Buffer, ShortNameEntry->Name.Buffer,
- ShortNameEntry->Name.Length);
- ShortName->Length = ShortNameEntry->Name.Length;
+ RtlCopyUnicodeString(ShortName, &ShortNameEntry->Name);
ExReleaseResourceLite(&DirectoryFcb->NameListResource);
DPRINT("Yield short name %wZ from cache\n", ShortName);
return;
@@ -218,13 +215,10 @@
}
ShortNameEntry->StreamOffset = *StreamOffset;
- ShortNameEntry->Name.Buffer = ShortNameEntry->NameBuffer;
- ShortNameEntry->Name.Length = ShortName->Length;
- ShortNameEntry->Name.MaximumLength = sizeof(ShortNameEntry->NameBuffer);
- RtlCopyMemory
- (ShortNameEntry->NameBuffer,
- ShortName->Buffer,
- ShortName->Length);
+ RtlInitEmptyUnicodeString(&ShortNameEntry->Name,
+ ShortNameEntry->NameBuffer,
+ sizeof(ShortNameEntry->NameBuffer));
+ RtlCopyUnicodeString(&ShortNameEntry->Name, ShortName);
InsertTailList(&DirectoryFcb->ShortNameList, &ShortNameEntry->Entry);
ExReleaseResourceLite(&DirectoryFcb->NameListResource);