From 1e88781ea43c41264ad2bfda544eca396864b863 Mon Sep 17 00:00:00 2001 From: basil00 Date: Fri, 7 Aug 2015 11:21:50 +0800 Subject: [PATCH] Bug fixes. - Fixed incorrect length calculation for the DNS response. (Tallow still "worked" despite this bug). - Add -mno-ms-bitfields flag to work-around bad attribute(packed) handling in recent versions of MinGW. --- Makefile | 2 +- redirect.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 350d7b7..dd6ec49 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CC = i686-w64-mingw32-gcc WINDRES = i686-w64-mingw32-windres CFLAGS = --std=c99 -O2 -I contrib/WinDivert-1.2.0-rc-MINGW/include/ -mwindows \ - -mthreads -m32 -Wall + -mthreads -mno-ms-bitfields -m32 -Wall CLIBS = -lws2_32 -lkernel32 -L contrib/WinDivert-1.2.0-rc-MINGW/x86/ \ -lWinDivert -lcomctl32 -mwindows OBJS = main.o redirect.o domain.o diff --git a/redirect.c b/redirect.c index 333e102..1986fd8 100644 --- a/redirect.c +++ b/redirect.c @@ -701,7 +701,7 @@ static void handle_dns(HANDLE handle, PWINDIVERT_ADDRESS addr, size_t len = sizeof(struct dnshdr) + data_len + sizeof(struct dnsa); if (len > 512) // Max DNS packet size. return; - len += sizeof(WINDIVERT_IPHDR) + sizeof(WINDIVERT_UDPHDR) + len; + len += sizeof(WINDIVERT_IPHDR) + sizeof(WINDIVERT_UDPHDR); char buf[len + 8]; // 8 bytes extra. PWINDIVERT_IPHDR riphdr = (PWINDIVERT_IPHDR)buf;