Fixed some length problems.

svn path=/trunk/; revision=13031
This commit is contained in:
Hartmut Birr 2005-01-13 20:54:13 +00:00
parent 7e23b350aa
commit 3360f1a1ae
4 changed files with 24 additions and 16 deletions

View file

@ -200,15 +200,8 @@ FindFile (PDEVICE_EXTENSION DeviceExt,
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;

View file

@ -306,7 +306,7 @@ NTSTATUS DoQuery (PVFAT_IRP_CONTEXT IrpContext)
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;

View file

@ -204,7 +204,7 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
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 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
}
/* 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;

View file

@ -461,14 +461,17 @@ vfatMakeFCBFromDirEntry(PVCB vcb,
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 @@ vfatDirFindFile (PDEVICE_EXTENSION pDeviceExt,
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;