mirror of
https://github.com/reactos/reactos.git
synced 2025-06-07 10:20:26 +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);
|
status = ZwQueryKey(ServiceHandle, KeyBasicInformation, NULL, 0, &infoLength);
|
||||||
if (status != STATUS_BUFFER_TOO_SMALL)
|
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 */
|
/* Allocate the buffer and retrieve the data */
|
||||||
basicInfo = ExAllocatePoolWithTag(PagedPool, infoLength, TAG_IO);
|
basicInfo = ExAllocatePoolWithTag(PagedPool, infoLength, TAG_IO);
|
||||||
if (!basicInfo)
|
if (!basicInfo)
|
||||||
{
|
{
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
status = STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
goto Cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = ZwQueryKey(ServiceHandle, KeyBasicInformation, basicInfo, infoLength, &infoLength);
|
status = ZwQueryKey(ServiceHandle, KeyBasicInformation, basicInfo, infoLength, &infoLength);
|
||||||
if (!NT_SUCCESS(status))
|
if (!NT_SUCCESS(status))
|
||||||
{
|
{
|
||||||
ExFreePoolWithTag(basicInfo, TAG_IO);
|
goto Cleanup;
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
serviceName.Length = basicInfo->NameLength;
|
serviceName.Length = basicInfo->NameLength;
|
||||||
|
@ -248,7 +249,6 @@ IopGetDriverNames(
|
||||||
PWCHAR buf = ExAllocatePoolWithTag(PagedPool, serviceName.Length, TAG_IO);
|
PWCHAR buf = ExAllocatePoolWithTag(PagedPool, serviceName.Length, TAG_IO);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
{
|
{
|
||||||
ExFreePoolWithTag(driverName.Buffer, TAG_IO);
|
|
||||||
status = STATUS_INSUFFICIENT_RESOURCES;
|
status = STATUS_INSUFFICIENT_RESOURCES;
|
||||||
goto Cleanup;
|
goto Cleanup;
|
||||||
}
|
}
|
||||||
|
@ -265,6 +265,9 @@ Cleanup:
|
||||||
if (basicInfo)
|
if (basicInfo)
|
||||||
ExFreePoolWithTag(basicInfo, TAG_IO);
|
ExFreePoolWithTag(basicInfo, TAG_IO);
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(status) && driverName.Buffer)
|
||||||
|
ExFreePoolWithTag(driverName.Buffer, TAG_IO);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue