Fix bignum bug & add more tests.

This commit is contained in:
basil00
2018-11-25 09:47:27 +08:00
parent 1c76a7c522
commit 2e334c9133
3 changed files with 11 additions and 0 deletions
+2
View File
@@ -2957,6 +2957,7 @@ extern BOOL WinDivertHelperEvalFilter(const char *filter, const VOID *packet,
case WINDIVERT_LAYER_NETWORK:
if (!addr->IPv6)
{
val[3] = val[2] = 0;
val[1] = 0x0000FFFF;
val[0] = ntohl((addr->Outbound? iphdr->SrcAddr:
iphdr->DstAddr));
@@ -3000,6 +3001,7 @@ extern BOOL WinDivertHelperEvalFilter(const char *filter, const VOID *packet,
case WINDIVERT_LAYER_NETWORK:
if (!addr->IPv6)
{
val[3] = val[2] = 0;
val[1] = 0x0000FFFF;
val[0] = ntohl((!addr->Outbound? iphdr->SrcAddr:
iphdr->DstAddr));
+2
View File
@@ -5470,6 +5470,7 @@ static BOOL windivert_filter(PNET_BUFFER buffer, WINDIVERT_LAYER layer,
case WINDIVERT_LAYER_NETWORK:
if (ipv4)
{
field[3] = field[2] = 0;
field[1] = 0x0000FFFF;
field[0] = (UINT32)RtlUlongByteSwap(
(outbound? ip_header->SrcAddr:
@@ -5521,6 +5522,7 @@ static BOOL windivert_filter(PNET_BUFFER buffer, WINDIVERT_LAYER layer,
case WINDIVERT_LAYER_NETWORK:
if (ipv4)
{
field[3] = field[2] = 0;
field[1] = 0x0000FFFF;
field[0] = (UINT32)RtlUlongByteSwap(
(!outbound? ip_header->SrcAddr:
+7
View File
@@ -366,6 +366,10 @@ static const struct test tests[] =
&pkt_dns_request, FALSE},
{"ip.DstAddr == ::ffff:8.8.4.4", &pkt_dns_request, TRUE},
{"ip.DstAddr == ::0:ffff:8.8.4.4", &pkt_dns_request, TRUE},
{"remoteAddr == 8.8.4.4", &pkt_dns_request, TRUE},
{"remoteAddr == ::ffff:8.8.4.4", &pkt_dns_request, TRUE},
{"protocol == 17", &pkt_dns_request, TRUE},
{"remotePort == 53", &pkt_dns_request, TRUE},
{"(ipv6? true: false) or (udp? udp.DstPort != 53: false) or "
"(not tcp and not udp? true: false)", &pkt_dns_request, FALSE},
{"ipv6 or (not tcp and udp.DstPort != 53)",&pkt_dns_request, FALSE},
@@ -437,6 +441,9 @@ static const struct test tests[] =
&pkt_ipv6_exthdrs_udp, TRUE},
{"udp.SrcPort == 4660 and udp.DstPort == 12345",
&pkt_ipv6_exthdrs_udp, FALSE},
{"localAddr == ::1", &pkt_ipv6_exthdrs_udp, TRUE},
{"localPort == 4660 and remotePort == 43690",
&pkt_ipv6_exthdrs_udp, TRUE},
{"(outbound and tcp? tcp.DstPort == 0xABAB: false) or "
"(outbound and udp? udp.DstPort == 0xAAAA: false) or "
"(inbound and tcp? tcp.SrcPort == 0xABAB: false) or "