mirror of
https://github.com/reactos/reactos.git
synced 2025-06-11 04:47:22 +00:00
- 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. svn path=/trunk/; revision=36291
This commit is contained in:
parent
6a59f3c2f8
commit
9a4bf1ea9c
2 changed files with 29 additions and 7 deletions
|
@ -1283,6 +1283,7 @@ IopQueryNameFile(IN PVOID ObjectBody,
|
||||||
PFILE_NAME_INFORMATION LocalFileInfo;
|
PFILE_NAME_INFORMATION LocalFileInfo;
|
||||||
PFILE_OBJECT FileObject = (PFILE_OBJECT)ObjectBody;
|
PFILE_OBJECT FileObject = (PFILE_OBJECT)ObjectBody;
|
||||||
ULONG LocalReturnLength, FileLength;
|
ULONG LocalReturnLength, FileLength;
|
||||||
|
BOOLEAN LengthMismatch = FALSE;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PWCHAR p;
|
PWCHAR p;
|
||||||
IOTRACE(IO_FILE_DEBUG, "ObjectBody: %p\n", ObjectBody);
|
IOTRACE(IO_FILE_DEBUG, "ObjectBody: %p\n", ObjectBody);
|
||||||
|
@ -1303,7 +1304,7 @@ IopQueryNameFile(IN PVOID ObjectBody,
|
||||||
LocalInfo,
|
LocalInfo,
|
||||||
Length,
|
Length,
|
||||||
&LocalReturnLength);
|
&LocalReturnLength);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status) && (Status != STATUS_INFO_LENGTH_MISMATCH))
|
||||||
{
|
{
|
||||||
/* Free the buffer and fail */
|
/* Free the buffer and fail */
|
||||||
ExFreePool(LocalInfo);
|
ExFreePool(LocalInfo);
|
||||||
|
@ -1326,9 +1327,13 @@ IopQueryNameFile(IN PVOID ObjectBody,
|
||||||
/* Check if this already filled our buffer */
|
/* Check if this already filled our buffer */
|
||||||
if (LocalReturnLength > Length)
|
if (LocalReturnLength > Length)
|
||||||
{
|
{
|
||||||
/* Free the buffer and fail */
|
/* Set the length mismatch to true, so that we can return
|
||||||
ExFreePool(LocalInfo);
|
* the proper buffer size to the caller later
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
*/
|
||||||
|
LengthMismatch = TRUE;
|
||||||
|
|
||||||
|
/* Save the initial buffer length value */
|
||||||
|
*ReturnLength = LocalReturnLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now get the file name buffer and check the length needed */
|
/* Now get the file name buffer and check the length needed */
|
||||||
|
@ -1340,7 +1345,7 @@ IopQueryNameFile(IN PVOID ObjectBody,
|
||||||
/* Query the File name */
|
/* Query the File name */
|
||||||
Status = IoQueryFileInformation(FileObject,
|
Status = IoQueryFileInformation(FileObject,
|
||||||
FileNameInformation,
|
FileNameInformation,
|
||||||
FileLength,
|
LengthMismatch ? Length : FileLength,
|
||||||
LocalFileInfo,
|
LocalFileInfo,
|
||||||
&LocalReturnLength);
|
&LocalReturnLength);
|
||||||
if (NT_ERROR(Status))
|
if (NT_ERROR(Status))
|
||||||
|
@ -1351,7 +1356,23 @@ IopQueryNameFile(IN PVOID ObjectBody,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ROS HACK. VFAT SUCKS */
|
/* 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 */
|
/* Now calculate the new lengths left */
|
||||||
FileLength = LocalReturnLength -
|
FileLength = LocalReturnLength -
|
||||||
|
|
|
@ -62,7 +62,8 @@ SeInitializeProcessAuditName(IN PFILE_OBJECT FileObject,
|
||||||
sizeof(LocalNameInfo),
|
sizeof(LocalNameInfo),
|
||||||
&ReturnLength);
|
&ReturnLength);
|
||||||
if (((Status == STATUS_BUFFER_OVERFLOW) ||
|
if (((Status == STATUS_BUFFER_OVERFLOW) ||
|
||||||
(Status == STATUS_BUFFER_TOO_SMALL)) &&
|
(Status == STATUS_BUFFER_TOO_SMALL) ||
|
||||||
|
(Status == STATUS_INFO_LENGTH_MISMATCH)) &&
|
||||||
(ReturnLength != sizeof(LocalNameInfo)))
|
(ReturnLength != sizeof(LocalNameInfo)))
|
||||||
{
|
{
|
||||||
/* Allocate required size */
|
/* Allocate required size */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue