Author: fireball
Date: Fri Aug 24 11:55:14 2007
New Revision: 28506
URL:
http://svn.reactos.org/svn/reactos?rev=28506&view=rev
Log:
Daniel Zimmerman <netzimme(a)aim.com>om>:
- Implement IoCheckEaBufferValidity()
Modified:
trunk/reactos/ntoskrnl/io/iomgr/file.c
trunk/reactos/ntoskrnl/io/iomgr/util.c
Modified: trunk/reactos/ntoskrnl/io/iomgr/file.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/file.c?r…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/file.c (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/file.c Fri Aug 24 11:55:14 2007
@@ -1637,6 +1637,8 @@
PVOID SystemEaBuffer = NULL;
NTSTATUS Status = STATUS_SUCCESS;
OPEN_PACKET OpenPacket;
+ ULONG EaErrorOffset;
+
PAGED_CODE();
IOTRACE(IO_FILE_DEBUG, "FileName: %wZ\n",
ObjectAttributes->ObjectName);
@@ -1732,10 +1734,11 @@
/* Validate the buffer */
Status = IoCheckEaBufferValidity(SystemEaBuffer,
EaLength,
- NULL);
+ &EaErrorOffset);
if (!NT_SUCCESS(Status))
{
- /* FIXME: Fail once function is implemented */
+ DPRINT1("FIXME: IoCheckEaBufferValidity() failed with "
+ "Status: %lx\n",Status);
}
}
}
Modified: trunk/reactos/ntoskrnl/io/iomgr/util.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/util.c?r…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/util.c (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/util.c Fri Aug 24 11:55:14 2007
@@ -130,7 +130,7 @@
}
/*
- * @unimplemented
+ * @implemented
*/
NTSTATUS
NTAPI
@@ -138,8 +138,77 @@
IN ULONG EaLength,
OUT PULONG ErrorOffset)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ PFILE_FULL_EA_INFORMATION EaBufferEnd;
+ ULONG NextEaBufferOffset, IntEaLength;
+
+ /* Lenght of the rest. Inital equal to EaLength */
+ IntEaLength = EaLength;
+
+ /* Inital EaBuffer equal to EaBuffer */
+ EaBufferEnd = EaBuffer;
+
+ /* The rest length of the buffer */
+ while (IntEaLength >= FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName[0]))
+ {
+ /* rest of buffer must greater then the
+ sizeof(FILE_FULL_EA_INFORMATION) + buffer */
+ NextEaBufferOffset =
+ EaBufferEnd->EaNameLength + EaBufferEnd->EaValueLength +
+ FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName[0]) + 1;
+
+ if (IntEaLength >= NextEaBufferOffset)
+ {
+ /* is the EaBufferName terminated with zero? */
+ if (EaBufferEnd->EaName[EaBufferEnd->EaNameLength]==0)
+ {
+ /* more EaBuffers ahead */
+ if (EaBufferEnd->NextEntryOffset == 0)
+ {
+ /* test the rest buffersize */
+ IntEaLength = IntEaLength - NextEaBufferOffset;
+ if (IntEaLength >= 0)
+ {
+ return STATUS_SUCCESS;
+ }
+ }
+ else
+ {
+ /* From the MSDN
+
http://msdn2.microsoft.com/en-us/library/ms795740.aspx
+ For all entries except the last, the value of
+ NextEntryOffset must be greater than zero and
+ must fall on a ULONG boundary
+ */
+ NextEaBufferOffset = ((NextEaBufferOffset + 3) & ~3);
+ if ((EaBufferEnd->NextEntryOffset == NextEaBufferOffset)
&&
+ (EaBufferEnd->NextEntryOffset>0))
+ {
+ /* Rest of buffer must be greater then the
+ next offset */
+ IntEaLength =
+ IntEaLength - EaBufferEnd->NextEntryOffset;
+
+ if (IntEaLength >= 0)
+ {
+ EaBufferEnd = (PFILE_FULL_EA_INFORMATION)
+ ((ULONG_PTR)EaBufferEnd +
+ EaBufferEnd->NextEntryOffset);
+ continue;
+ }
+ }
+ }
+ }
+ }
+ break;
+ }
+
+ if (ErrorOffset != NULL)
+ {
+ /* Calculate the error offset */
+ *ErrorOffset = (ULONG)((ULONG_PTR)EaBufferEnd - (ULONG_PTR)EaBuffer);
+ }
+
+ return STATUS_EA_LIST_INCONSISTENT;
}
/*