Modified: trunk/reactos/drivers/fs/vfat/create.c
Modified: trunk/reactos/drivers/fs/vfat/dir.c
Modified: trunk/reactos/drivers/fs/vfat/dirwr.c
Modified: trunk/reactos/drivers/fs/vfat/fcb.c
--- trunk/reactos/drivers/fs/vfat/create.c 2005-01-13 20:53:35 UTC (rev 13030)
+++ trunk/reactos/drivers/fs/vfat/create.c 2005-01-13 20:54:13 UTC (rev 13031)
@@ -200,15 +200,8 @@
Parent, FileToFindU, DirContext->DirIndex);
DPRINT ("FindFile: Path %wZ)\n",&Parent->PathNameU);
- PathNameBufferLength = Parent->PathNameU.Length + LONGNAME_MAX_LENGTH + 2 * sizeof(WCHAR);
- if (PathNameBufferLength > (USHRT_MAX - 2) * sizeof(WCHAR))
- {
- /* A valid filename can't be so long. Do as if the file doesn't exist. */
- CHECKPOINT;
- return STATUS_NO_SUCH_FILE;
- }
-
- PathNameBuffer = ExAllocatePool(NonPagedPool, PathNameBufferLength);
+ PathNameBufferLength = LONGNAME_MAX_LENGTH * sizeof(WCHAR);
+ PathNameBuffer = ExAllocatePool(NonPagedPool, PathNameBufferLength + sizeof(WCHAR));
if (!PathNameBuffer)
{
CHECKPOINT1;
--- trunk/reactos/drivers/fs/vfat/dir.c 2005-01-13 20:53:35 UTC (rev 13030)
+++ trunk/reactos/drivers/fs/vfat/dir.c 2005-01-13 20:54:13 UTC (rev 13031)
@@ -306,7 +306,7 @@
BOOLEAN First = FALSE;
BOOLEAN FirstCall;
VFAT_DIRENTRY_CONTEXT DirContext;
- WCHAR LongNameBuffer[LONGNAME_MAX_LENGTH];
+ WCHAR LongNameBuffer[LONGNAME_MAX_LENGTH + 1];
WCHAR ShortNameBuffer[13];
PIO_STACK_LOCATION Stack = IrpContext->Stack;
--- trunk/reactos/drivers/fs/vfat/dirwr.c 2005-01-13 20:53:35 UTC (rev 13030)
+++ trunk/reactos/drivers/fs/vfat/dirwr.c 2005-01-13 20:54:13 UTC (rev 13031)
@@ -204,7 +204,7 @@
BOOLEAN SpacesFound;
VFAT_DIRENTRY_CONTEXT DirContext;
- WCHAR LongNameBuffer[LONGNAME_MAX_LENGTH];
+ WCHAR LongNameBuffer[LONGNAME_MAX_LENGTH + 1];
WCHAR ShortNameBuffer[13];
DPRINT ("addEntry: Name='%wZ', Dir='%wZ'\n", NameU, &ParentFcb->PathNameU);
@@ -363,6 +363,16 @@
}
/* set dates and times */
KeQuerySystemTime (&SystemTime);
+#if 0
+ {
+ TIME_FIELDS tf;
+ RtlTimeToTimeFields (&SystemTime, &tf);
+ DPRINT1("%d.%d.%d %02d:%02d:%02d.%03d '%wZ'\n",
+ tf.Day, tf.Month, tf.Year, tf.Hour,
+ tf.Minute, tf.Second, tf.Milliseconds,
+ NameU);
+ }
+#endif
FsdSystemTimeToDosDateTime (DeviceExt, &SystemTime, &DirContext.DirEntry.Fat.CreationDate,
&DirContext.DirEntry.Fat.CreationTime);
DirContext.DirEntry.Fat.UpdateDate = DirContext.DirEntry.Fat.CreationDate;
--- trunk/reactos/drivers/fs/vfat/fcb.c 2005-01-13 20:53:35 UTC (rev 13030)
+++ trunk/reactos/drivers/fs/vfat/fcb.c 2005-01-13 20:54:13 UTC (rev 13031)
@@ -461,14 +461,17 @@
UNICODE_STRING NameU;
- PathNameLength = (directoryFCB->PathNameU.Length + 2 * sizeof(WCHAR)
- + DirContext->LongNameU.Length) * sizeof(WCHAR);
+ PathNameLength = directoryFCB->PathNameU.Length + max(DirContext->LongNameU.Length, DirContext->ShortNameU.Length);
+ if (!vfatFCBIsRoot (directoryFCB))
+ {
+ PathNameLength += sizeof(WCHAR);
+ }
- if (PathNameLength > (USHRT_MAX - 2) * sizeof(WCHAR))
+ if (PathNameLength > LONGNAME_MAX_LENGTH * sizeof(WCHAR))
{
return STATUS_OBJECT_NAME_INVALID;
}
- PathNameBuffer = ExAllocatePool(NonPagedPool, PathNameLength);
+ PathNameBuffer = ExAllocatePool(NonPagedPool, PathNameLength + sizeof(WCHAR));
if (!PathNameBuffer)
{
return STATUS_INSUFFICIENT_RESOURCES;
@@ -585,7 +588,9 @@
PVOID Page = NULL;
BOOLEAN First = TRUE;
VFAT_DIRENTRY_CONTEXT DirContext;
- WCHAR LongNameBuffer[LONGNAME_MAX_LENGTH];
+ /* This buffer must have a size of 260 characters, because
+ vfatMakeFCBFromDirEntry can copy 20 name entries with 13 characters. */
+ WCHAR LongNameBuffer[260];
WCHAR ShortNameBuffer[13];
BOOLEAN FoundLong = FALSE;
BOOLEAN FoundShort = FALSE;