[NTOSKRNL] In IopQueryNameInternal(), enclose output copy in a SEH statement

This commit is contained in:
Pierre Schweitzer 2018-10-03 22:55:23 +02:00
parent 15b9a6aa4c
commit d8f22735ed
No known key found for this signature in database
GPG key ID: 7545556C3D585B0B

View file

@ -1975,6 +1975,8 @@ IopQueryNameInternal(IN PVOID ObjectBody,
/* Get buffer pointer */
p = (PWCHAR)(ObjectNameInfo + 1);
_SEH2_TRY
{
/* Copy the information */
if (QueryDosName && NoObCall)
{
@ -2049,8 +2051,7 @@ IopQueryNameInternal(IN PVOID ObjectBody,
if (Status != STATUS_INVALID_PARAMETER && Status != STATUS_INVALID_DEVICE_REQUEST &&
Status != STATUS_NOT_IMPLEMENTED && Status != STATUS_INVALID_INFO_CLASS)
{
ExFreePoolWithTag(LocalInfo, TAG_IO);
return Status;
_SEH2_LEAVE;
}
/* In such case, zero output */
@ -2074,8 +2075,8 @@ IopQueryNameInternal(IN PVOID ObjectBody,
*ReturnLength += LocalFileInfo->FileNameLength;
/* Free the allocated buffer and return failure */
ExFreePoolWithTag(LocalInfo, TAG_IO);
return STATUS_BUFFER_OVERFLOW;
Status = STATUS_BUFFER_OVERFLOW;
_SEH2_LEAVE;
}
/* Now calculate the new lengths left */
@ -2089,8 +2090,8 @@ IopQueryNameInternal(IN PVOID ObjectBody,
if (LocalFileInfo->FileName[0] != OBJ_NAME_PATH_SEPARATOR)
{
/* Free the allocated buffer and return failure */
ExFreePoolWithTag(LocalInfo, TAG_IO);
return STATUS_OBJECT_PATH_INVALID;
Status = STATUS_OBJECT_PATH_INVALID;
_SEH2_LEAVE;
}
/* Write the Name and null-terminate it */
@ -2108,9 +2109,13 @@ IopQueryNameInternal(IN PVOID ObjectBody,
sizeof(OBJECT_NAME_INFORMATION);
ObjectNameInfo->Name.MaximumLength = (USHORT)ObjectNameInfo->Name.Length +
sizeof(UNICODE_NULL);
}
_SEH2_FINALLY
{
/* Free buffer and return */
ExFreePoolWithTag(LocalInfo, TAG_IO);
} _SEH2_END;
return Status;
}