Skip to content

Commit

Permalink
Allow filter sets that reduce the filter, not just increase
Browse files Browse the repository at this point in the history
Previous behavior would only pass along filters that added new bits
(filters) to the current filter set, without considering whether some
bits were set only by the old HigherPacketFilter. Possibly related
to nmap#106, since this code was one of few changes in v0.9990.
  • Loading branch information
bonsaiviking committed Feb 2, 2021
1 parent 2fed31c commit 7ea7deb
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packetWin7/npf/npf/Openclos.c
Original file line number Diff line number Diff line change
Expand Up @@ -2609,12 +2609,11 @@ NOTE: Called at <= DISPATCH_LEVEL (unlike a miniport's MiniportOidRequest)

TRACE_ENTER();

// Special case: if they're trying to set a packet filter that is a
// subset of our existing one, then we don't pass it down but just
// return success.
// Special case: if their new packet filter doesn't change the lower one
// then we don't pass it down but just return success.
if (Request->RequestType == NdisRequestSetInformation
&& Request->DATA.SET_INFORMATION.Oid == OID_GEN_CURRENT_PACKET_FILTER
&& (*(PULONG) Request->DATA.SET_INFORMATION.InformationBuffer & ~(pFiltMod->HigherPacketFilter | pFiltMod->MyPacketFilter)) == 0)
&& (*(PULONG) Request->DATA.SET_INFORMATION.InformationBuffer | pFiltMod->MyPacketFilter) == (pFiltMod->HigherPacketFilter | pFiltMod->MyPacketFilter))
{
pFiltMod->HigherPacketFilter = *(PULONG) Request->DATA.SET_INFORMATION.InformationBuffer;
Request->DATA.SET_INFORMATION.BytesRead = sizeof(ULONG);
Expand Down Expand Up @@ -3230,7 +3229,7 @@ NPF_SetPacketFilter(
#endif
// If the new packet filter is the same as the old one...
if (NewPacketFilter == pFiltMod->MyPacketFilter
// ...or it wouldn't change the upper one
// ...or it wouldn't add to the upper one
|| (NewPacketFilter & (~pFiltMod->HigherPacketFilter)) == 0)
{
pFiltMod->MyPacketFilter = NewPacketFilter;
Expand Down

0 comments on commit 7ea7deb

Please sign in to comment.