Skip to content

Commit

Permalink
Check for alloc failure. Fixes nmap#698
Browse files Browse the repository at this point in the history
  • Loading branch information
dmiller-nmap committed Oct 5, 2023
1 parent 908a6d8 commit 4615b28
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packetWin7/npf/npf/Openclos.c
Original file line number Diff line number Diff line change
Expand Up @@ -1934,6 +1934,17 @@ NPF_CreateFilterModule(
bAllocFailed = TRUE;
break;
}

pFiltMod->AdapterName.MaximumLength = AdapterName->MaximumLength - DEVICE_PATH_BYTES;
pFiltMod->AdapterName.Buffer = ExAllocatePoolWithTag(NPF_NONPAGED, pFiltMod->AdapterName.MaximumLength, NPF_UNICODE_BUFFER_TAG);
if (pFiltMod->AdapterName.Buffer == NULL)
{
INFO_DBG("Failed to allocate AdapterName buffer\n");
bAllocFailed = TRUE;
break;
}
pFiltMod->AdapterName.Length = 0;
RtlAppendUnicodeToString(&pFiltMod->AdapterName, AdapterName->Buffer + DEVICE_PATH_CCH);
} while (0);

if (bAllocFailed) {
Expand All @@ -1951,11 +1962,6 @@ NPF_CreateFilterModule(
// or for Loopback when creating the fake module.
pFiltMod->MaxFrameSize = 1514;

pFiltMod->AdapterName.MaximumLength = AdapterName->MaximumLength - DEVICE_PATH_BYTES;
pFiltMod->AdapterName.Buffer = ExAllocatePoolWithTag(NPF_NONPAGED, pFiltMod->AdapterName.MaximumLength, NPF_UNICODE_BUFFER_TAG);
pFiltMod->AdapterName.Length = 0;
RtlAppendUnicodeToString(&pFiltMod->AdapterName, AdapterName->Buffer + DEVICE_PATH_CCH);

//
//allocate the spinlock for the OID requests
//
Expand Down

0 comments on commit 4615b28

Please sign in to comment.