Author: fireball
Date: Wed Sep 17 13:38:14 2008
New Revision: 36291
URL:
http://svn.reactos.org/svn/reactos?rev=36291&view=rev
Log:
- ObQueryNameString can return STATUS_INFO_LENGTH_MISMATCH, so make sure
SeInitializeProcessAuditName supports that along with BUFFER_OVERFLOW and
BUFFER_TOO_SMALL, which an Ob query name procedure could return.
- ObQueryNameString can return STATUS_INFO_LENGTH_MISMATCH, take this into account and
report a proper buffer length to the caller in IopQueryNameFile.
Modified:
trunk/reactos/ntoskrnl/io/iomgr/file.c
trunk/reactos/ntoskrnl/se/audit.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 [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/file.c [iso-8859-1] Wed Sep 17 13:38:14 2008
@@ -1283,6 +1283,7 @@
PFILE_NAME_INFORMATION LocalFileInfo;
PFILE_OBJECT FileObject = (PFILE_OBJECT)ObjectBody;
ULONG LocalReturnLength, FileLength;
+ BOOLEAN LengthMismatch = FALSE;
NTSTATUS Status;
PWCHAR p;
IOTRACE(IO_FILE_DEBUG, "ObjectBody: %p\n", ObjectBody);
@@ -1303,7 +1304,7 @@
LocalInfo,
Length,
&LocalReturnLength);
- if (!NT_SUCCESS(Status))
+ if (!NT_SUCCESS(Status) && (Status != STATUS_INFO_LENGTH_MISMATCH))
{
/* Free the buffer and fail */
ExFreePool(LocalInfo);
@@ -1326,9 +1327,13 @@
/* Check if this already filled our buffer */
if (LocalReturnLength > Length)
{
- /* Free the buffer and fail */
- ExFreePool(LocalInfo);
- return STATUS_BUFFER_OVERFLOW;
+ /* Set the length mismatch to true, so that we can return
+ * the proper buffer size to the caller later
+ */
+ LengthMismatch = TRUE;
+
+ /* Save the initial buffer length value */
+ *ReturnLength = LocalReturnLength;
}
/* Now get the file name buffer and check the length needed */
@@ -1340,7 +1345,7 @@
/* Query the File name */
Status = IoQueryFileInformation(FileObject,
FileNameInformation,
- FileLength,
+ LengthMismatch ? Length : FileLength,
LocalFileInfo,
&LocalReturnLength);
if (NT_ERROR(Status))
@@ -1351,7 +1356,23 @@
}
/* ROS HACK. VFAT SUCKS */
- if (NT_WARNING(Status)) LocalReturnLength = FileLength;
+ if (NT_WARNING(Status))
+ {
+ DPRINT("Status 0x%08x, LRN 0x%x, FileLength 0x%x\n", Status,
+ LocalReturnLength, FileLength);
+ LocalReturnLength = FileLength;
+ }
+
+ /* If the provided buffer is too small, return the required size */
+ if (LengthMismatch)
+ {
+ /* Add the required length */
+ *ReturnLength += LocalFileInfo->FileNameLength;
+
+ /* Free the allocated buffer and return failure */
+ ExFreePool(LocalInfo);
+ return STATUS_BUFFER_OVERFLOW;
+ }
/* Now calculate the new lengths left */
FileLength = LocalReturnLength -
Modified: trunk/reactos/ntoskrnl/se/audit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/se/audit.c?rev=36…
==============================================================================
--- trunk/reactos/ntoskrnl/se/audit.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/se/audit.c [iso-8859-1] Wed Sep 17 13:38:14 2008
@@ -62,7 +62,8 @@
sizeof(LocalNameInfo),
&ReturnLength);
if (((Status == STATUS_BUFFER_OVERFLOW) ||
- (Status == STATUS_BUFFER_TOO_SMALL)) &&
+ (Status == STATUS_BUFFER_TOO_SMALL) ||
+ (Status == STATUS_INFO_LENGTH_MISMATCH)) &&
(ReturnLength != sizeof(LocalNameInfo)))
{
/* Allocate required size */