From 2e334c9133b968606507f0875f54a1c794b4d5ba Mon Sep 17 00:00:00 2001 From: basil00 Date: Sun, 25 Nov 2018 09:47:27 +0800 Subject: [PATCH] Fix bignum bug & add more tests. --- dll/windivert_helper.c | 2 ++ sys/windivert.c | 2 ++ test/test.c | 7 +++++++ 3 files changed, 11 insertions(+) diff --git a/dll/windivert_helper.c b/dll/windivert_helper.c index dc44a45..7171982 100644 --- a/dll/windivert_helper.c +++ b/dll/windivert_helper.c @@ -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)); diff --git a/sys/windivert.c b/sys/windivert.c index c0acbd2..bda51aa 100644 --- a/sys/windivert.c +++ b/sys/windivert.c @@ -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: diff --git a/test/test.c b/test/test.c index 4c2fdb1..0c34738 100644 --- a/test/test.c +++ b/test/test.c @@ -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 "