mirror of
https://github.com/reactos/reactos.git
synced 2025-06-01 15:38:37 +00:00
[NTOS:IO] Fix driverName.Buffer leak in some failure paths in IopGetDriverNames().
driverName.Buffer leaked when the "(!NT_SUCCESS(status) || ServiceName != NULL)" case is taken because ServiceName != NULL, and some of the functions fail.
This commit is contained in:
parent
e09d1dec7a
commit
32a82eb123
1 changed files with 8 additions and 5 deletions
|
@ -171,21 +171,22 @@ IopGetDriverNames(
|
|||
status = ZwQueryKey(ServiceHandle, KeyBasicInformation, NULL, 0, &infoLength);
|
||||
if (status != STATUS_BUFFER_TOO_SMALL)
|
||||
{
|
||||
return NT_SUCCESS(status) ? STATUS_UNSUCCESSFUL : status;
|
||||
status = (NT_SUCCESS(status) ? STATUS_UNSUCCESSFUL : status);
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
/* Allocate the buffer and retrieve the data */
|
||||
basicInfo = ExAllocatePoolWithTag(PagedPool, infoLength, TAG_IO);
|
||||
if (!basicInfo)
|
||||
{
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
status = ZwQueryKey(ServiceHandle, KeyBasicInformation, basicInfo, infoLength, &infoLength);
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
ExFreePoolWithTag(basicInfo, TAG_IO);
|
||||
return status;
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
serviceName.Length = basicInfo->NameLength;
|
||||
|
@ -248,7 +249,6 @@ IopGetDriverNames(
|
|||
PWCHAR buf = ExAllocatePoolWithTag(PagedPool, serviceName.Length, TAG_IO);
|
||||
if (!buf)
|
||||
{
|
||||
ExFreePoolWithTag(driverName.Buffer, TAG_IO);
|
||||
status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
goto Cleanup;
|
||||
}
|
||||
|
@ -265,6 +265,9 @@ Cleanup:
|
|||
if (basicInfo)
|
||||
ExFreePoolWithTag(basicInfo, TAG_IO);
|
||||
|
||||
if (!NT_SUCCESS(status) && driverName.Buffer)
|
||||
ExFreePoolWithTag(driverName.Buffer, TAG_IO);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue