Added patches to fix several issues in wpcap.

This commit is contained in:
Sebastian Lackner 2016-01-14 08:33:09 +01:00
parent 7b0d10f1f4
commit a82ee1887f
6 changed files with 182 additions and 31 deletions

View File

@ -343,6 +343,7 @@ patch_enable_all ()
enable_winspool_drv_SetPrinterW="$1"
enable_winsta_WinStationEnumerateW="$1"
enable_wpcap_Dynamic_Linking="$1"
enable_wpcap_Several_Fixes="$1"
enable_ws2_32_APC_Performance="$1"
enable_ws2_32_Connect_Time="$1"
enable_ws2_32_Sort_default_route="$1"
@ -1153,6 +1154,9 @@ patch_enable ()
wpcap-Dynamic_Linking)
enable_wpcap_Dynamic_Linking="$2"
;;
wpcap-Several_Fixes)
enable_wpcap_Several_Fixes="$2"
;;
ws2_32-APC_Performance)
enable_ws2_32_APC_Performance="$2"
;;
@ -1722,9 +1726,6 @@ if test "$enable_category_stable" -eq 1; then
if test "$enable_winmm_Delay_Import_Depends" -gt 1; then
abort "Patchset winmm-Delay_Import_Depends disabled, but category-stable depends on that."
fi
if test "$enable_wpcap_Dynamic_Linking" -gt 1; then
abort "Patchset wpcap-Dynamic_Linking disabled, but category-stable depends on that."
fi
if test "$enable_ws2_32_Connect_Time" -gt 1; then
abort "Patchset ws2_32-Connect_Time disabled, but category-stable depends on that."
fi
@ -1793,7 +1794,6 @@ if test "$enable_category_stable" -eq 1; then
enable_winex11_wglShareLists=1
enable_wininet_ParseX509EncodedCertificateForListBoxEntry=1
enable_winmm_Delay_Import_Depends=1
enable_wpcap_Dynamic_Linking=1
enable_ws2_32_Connect_Time=1
enable_ws2_32_WriteWatches=1
fi
@ -1812,6 +1812,13 @@ if test "$enable_ws2_32_TransmitFile" -eq 1; then
enable_server_Desktop_Refcount=1
fi
if test "$enable_wpcap_Dynamic_Linking" -eq 1; then
if test "$enable_wpcap_Several_Fixes" -gt 1; then
abort "Patchset wpcap-Several_Fixes disabled, but wpcap-Dynamic_Linking depends on that."
fi
enable_wpcap_Several_Fixes=1
fi
if test "$enable_wined3d_CSMT_Main" -eq 1; then
if test "$enable_wined3d_CSMT_Helper" -gt 1; then
abort "Patchset wined3d-CSMT_Helper disabled, but wined3d-CSMT_Main depends on that."
@ -6811,8 +6818,25 @@ if test "$enable_winsta_WinStationEnumerateW" -eq 1; then
) >> "$patchlist"
fi
# Patchset wpcap-Several_Fixes
# |
# | Modified files:
# | * dlls/wpcap/wpcap.c, dlls/wpcap/wpcap.spec
# |
if test "$enable_wpcap_Several_Fixes" -eq 1; then
patch_apply wpcap-Several_Fixes/0001-wpcap-Implement-pcap_dump_open-and-pcap_dump.patch
patch_apply wpcap-Several_Fixes/0002-wpcap-Fix-crash-on-pcap_loop.patch
(
echo '+ { "Jianqiu Zhang", "wpcap: Implement pcap_dump_open and pcap_dump.", 1 },';
echo '+ { "Jianqiu Zhang", "wpcap: Fix crash on pcap_loop.", 1 },';
) >> "$patchlist"
fi
# Patchset wpcap-Dynamic_Linking
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * wpcap-Several_Fixes
# |
# | Modified files:
# | * configure.ac, dlls/wpcap/Makefile.in, dlls/wpcap/wpcap.c
# |

View File

@ -1,4 +1,4 @@
From 811b0381cc2979ba6dee508e0f497e50d2ed499d Mon Sep 17 00:00:00 2001
From 09e0c732f3c13f7ac1ba8c40e918092c642051a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Hentschel?= <nerv@dawncrow.de>
Date: Tue, 26 Aug 2014 00:59:37 +0200
Subject: wpcap: Load libpcap dynamically.
@ -8,14 +8,14 @@ Something we don't want i guess.
---
configure.ac | 6 +-
dlls/wpcap/Makefile.in | 1 -
dlls/wpcap/wpcap.c | 163 +++++++++++++++++++++++++++++++++++++++----------
3 files changed, 134 insertions(+), 36 deletions(-)
dlls/wpcap/wpcap.c | 171 +++++++++++++++++++++++++++++++++++++++----------
3 files changed, 140 insertions(+), 38 deletions(-)
diff --git a/configure.ac b/configure.ac
index aec53f6..58112de 100644
index 811e2aa..30b500a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1288,11 +1288,11 @@ test "x$ac_cv_lib_OpenCL_clGetPlatformInfo" != xyes && enable_opencl=${enable_op
@@ -1182,11 +1182,11 @@ test "x$ac_cv_lib_OpenCL_clGetPlatformInfo" != xyes && enable_opencl=${enable_op
dnl **** Check for libpcap ****
if test "$ac_cv_header_pcap_pcap_h" = "yes"
then
@ -31,7 +31,7 @@ index aec53f6..58112de 100644
dnl **** Check for libxml2 ****
diff --git a/dlls/wpcap/Makefile.in b/dlls/wpcap/Makefile.in
index e44613f..aeef71a 100644
index 91b4a95..aeef71a 100644
--- a/dlls/wpcap/Makefile.in
+++ b/dlls/wpcap/Makefile.in
@@ -1,6 +1,5 @@
@ -42,7 +42,7 @@ index e44613f..aeef71a 100644
C_SRCS = \
wpcap.c
diff --git a/dlls/wpcap/wpcap.c b/dlls/wpcap/wpcap.c
index ae9e482..3e5c82b 100644
index 44e8c2a..f9029c8 100644
--- a/dlls/wpcap/wpcap.c
+++ b/dlls/wpcap/wpcap.c
@@ -18,6 +18,9 @@
@ -55,7 +55,7 @@ index ae9e482..3e5c82b 100644
#include <pcap/pcap.h>
#include "winsock2.h"
#include "windef.h"
@@ -40,47 +43,124 @@ WINE_DECLARE_DEBUG_CHANNEL(winediag);
@@ -40,47 +43,128 @@ WINE_DECLARE_DEBUG_CHANNEL(winediag);
#define PCAP_SRC_IFLOCAL 3
#endif
@ -67,6 +67,8 @@ index ae9e482..3e5c82b 100644
+static const char* (*ppcap_datalink_val_to_description)(int);
+static const char* (*ppcap_datalink_val_to_name)(int);
+static int (*ppcap_dispatch)(pcap_t *, int, pcap_handler, u_char *);
+static void (*ppcap_dump)(u_char *, const struct pcap_pkthdr *, const u_char *);
+static pcap_dumper_t* (*ppcap_dump_open)(pcap_t *, const char *);
+static int (*ppcap_findalldevs)(pcap_if_t **, char *);
+static void (*ppcap_freealldevs)(pcap_if_t *);
+static void (*ppcap_freecode)(struct bpf_program *);
@ -110,6 +112,8 @@ index ae9e482..3e5c82b 100644
+ LOAD_FUNCPTR(pcap_datalink_val_to_description);
+ LOAD_FUNCPTR(pcap_datalink_val_to_name);
+ LOAD_FUNCPTR(pcap_dispatch);
+ LOAD_FUNCPTR(pcap_dump);
+ LOAD_FUNCPTR(pcap_dump_open);
+ LOAD_FUNCPTR(pcap_findalldevs);
+ LOAD_FUNCPTR(pcap_freealldevs);
+ LOAD_FUNCPTR(pcap_freecode);
@ -187,12 +191,14 @@ index ae9e482..3e5c82b 100644
}
typedef struct
@@ -111,10 +191,10 @@ int CDECL wine_pcap_dispatch(pcap_t *p, int cnt,
@@ -112,12 +196,12 @@ int CDECL wine_pcap_dispatch(pcap_t *p, int cnt,
pcb = HeapAlloc(GetProcessHeap(), 0, sizeof(PCAP_HANDLER_CALLBACK));
pcb->pfn_cb = callback;
pcb->user_data = user;
- return pcap_dispatch(p, cnt, pcap_handler_callback, (unsigned char*)pcb);
+ return ppcap_dispatch(p, cnt, pcap_handler_callback, (unsigned char*)pcb);
- res = pcap_dispatch(p, cnt, pcap_handler_callback, (unsigned char *)pcb);
+ res = ppcap_dispatch(p, cnt, pcap_handler_callback, (unsigned char *)pcb);
HeapFree(GetProcessHeap(), 0, pcb);
return res;
}
- return pcap_dispatch(p, cnt, NULL, user);
@ -200,7 +206,7 @@ index ae9e482..3e5c82b 100644
}
int CDECL wine_pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
@@ -122,7 +202,7 @@ int CDECL wine_pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
@@ -125,7 +209,7 @@ int CDECL wine_pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
int ret;
TRACE("(%p %p)\n", alldevsp, errbuf);
@ -209,7 +215,7 @@ index ae9e482..3e5c82b 100644
if(alldevsp && !*alldevsp)
ERR_(winediag)("Failed to access raw network (pcap), this requires special permissions.\n");
@@ -138,13 +218,13 @@ int CDECL wine_pcap_findalldevs_ex(char *source, void *auth, pcap_if_t **alldevs
@@ -141,13 +225,13 @@ int CDECL wine_pcap_findalldevs_ex(char *source, void *auth, pcap_if_t **alldevs
void CDECL wine_pcap_freealldevs(pcap_if_t *alldevs)
{
TRACE("(%p)\n", alldevs);
@ -225,7 +231,7 @@ index ae9e482..3e5c82b 100644
}
typedef struct _AirpcapHandle *PAirpcapHandle;
@@ -157,18 +237,18 @@ PAirpcapHandle CDECL wine_pcap_get_airpcap_handle(pcap_t *p)
@@ -160,18 +244,18 @@ PAirpcapHandle CDECL wine_pcap_get_airpcap_handle(pcap_t *p)
char* CDECL wine_pcap_geterr(pcap_t *p)
{
TRACE("(%p)\n", p);
@ -247,7 +253,7 @@ index ae9e482..3e5c82b 100644
TRACE("%s\n", debugstr_a(ret));
return ret;
}
@@ -176,20 +256,20 @@ const char* CDECL wine_pcap_lib_version(void)
@@ -179,20 +263,20 @@ const char* CDECL wine_pcap_lib_version(void)
int CDECL wine_pcap_list_datalinks(pcap_t *p, int **dlt_buffer)
{
TRACE("(%p %p)\n", p, dlt_buffer);
@ -271,12 +277,14 @@ index ae9e482..3e5c82b 100644
}
int CDECL wine_pcap_loop(pcap_t *p, int cnt,
@@ -204,34 +284,34 @@ int CDECL wine_pcap_loop(pcap_t *p, int cnt,
@@ -209,36 +293,36 @@ int CDECL wine_pcap_loop(pcap_t *p, int cnt,
pcb = HeapAlloc(GetProcessHeap(), 0, sizeof(PCAP_HANDLER_CALLBACK));
pcb->pfn_cb = callback;
pcb->user_data = user;
- return pcap_loop(p, cnt, pcap_handler_callback, (unsigned char*)pcb);
+ return ppcap_loop(p, cnt, pcap_handler_callback, (unsigned char*)pcb);
- res = pcap_loop(p, cnt, pcap_handler_callback, (unsigned char *)pcb);
+ res = ppcap_loop(p, cnt, pcap_handler_callback, (unsigned char *)pcb);
HeapFree(GetProcessHeap(), 0, pcb);
return res;
}
- return pcap_loop(p, cnt, NULL, user);
@ -312,7 +320,7 @@ index ae9e482..3e5c82b 100644
}
#define PCAP_OPENFLAG_PROMISCUOUS 1
@@ -242,14 +322,14 @@ pcap_t* CDECL wine_pcap_open(const char *source, int snaplen, int flags, int rea
@@ -249,14 +333,14 @@ pcap_t* CDECL wine_pcap_open(const char *source, int snaplen, int flags, int rea
int promisc = flags & PCAP_OPENFLAG_PROMISCUOUS;
FIXME("(%s %i %i %i %p %p): partial stub\n", debugstr_a(source), snaplen, flags, read_timeout,
auth, errbuf);
@ -329,7 +337,7 @@ index ae9e482..3e5c82b 100644
}
int CDECL wine_pcap_parsesrcstr(const char *source, int *type, char *host, char *port, char *name, char *errbuf)
@@ -293,13 +373,13 @@ int CDECL wine_pcap_parsesrcstr(const char *source, int *type, char *host, char
@@ -300,13 +384,13 @@ int CDECL wine_pcap_parsesrcstr(const char *source, int *type, char *host, char
int CDECL wine_pcap_sendpacket(pcap_t *p, const unsigned char *buf, int size)
{
TRACE("(%p %p %i)\n", p, buf, size);
@ -345,7 +353,7 @@ index ae9e482..3e5c82b 100644
}
int CDECL wine_pcap_setbuff(pcap_t * p, int dim)
@@ -311,25 +391,25 @@ int CDECL wine_pcap_setbuff(pcap_t * p, int dim)
@@ -318,25 +402,25 @@ int CDECL wine_pcap_setbuff(pcap_t * p, int dim)
int CDECL wine_pcap_setfilter(pcap_t *p, struct bpf_program *fp)
{
TRACE("(%p %p)\n", p, fp);
@ -375,10 +383,19 @@ index ae9e482..3e5c82b 100644
}
int CDECL wine_wsockinit(void)
@@ -339,3 +419,22 @@ int CDECL wine_wsockinit(void)
if (WSAStartup(MAKEWORD(1,1), &wsadata)) return -1;
return 0;
@@ -349,10 +433,29 @@ int CDECL wine_wsockinit(void)
pcap_dumper_t* CDECL wine_pcap_dump_open(pcap_t *p, const char *fname)
{
- return pcap_dump_open(p, fname);
+ return ppcap_dump_open(p, fname);
}
void CDECL wine_pcap_dump(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
{
- return pcap_dump(user, h, sp);
+ return ppcap_dump(user, h, sp);
+}
+
+BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
@ -397,7 +414,7 @@ index ae9e482..3e5c82b 100644
+ }
+
+ return TRUE;
+}
}
--
2.5.0
2.6.4

View File

@ -1 +1 @@
Category: stable
Depends: wpcap-Several_Fixes

View File

@ -0,0 +1,51 @@
From 9e5dd79c03afddd6a3d327b33cef358b849e891d Mon Sep 17 00:00:00 2001
From: Jianqiu Zhang <zhangjianqiu_133@yeah.net>
Date: Thu, 7 Jan 2016 16:33:34 +0800
Subject: wpcap: Implement pcap_dump_open and pcap_dump
Signed-off-by: Jianqiu Zhang <zhangjianqiu_133@yeah.net>
---
dlls/wpcap/wpcap.c | 10 ++++++++++
dlls/wpcap/wpcap.spec | 4 ++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/dlls/wpcap/wpcap.c b/dlls/wpcap/wpcap.c
index ae9e482..da911c7 100644
--- a/dlls/wpcap/wpcap.c
+++ b/dlls/wpcap/wpcap.c
@@ -339,3 +339,13 @@ int CDECL wine_wsockinit(void)
if (WSAStartup(MAKEWORD(1,1), &wsadata)) return -1;
return 0;
}
+
+pcap_dumper_t* CDECL wine_pcap_dump_open(pcap_t *p, const char *fname)
+{
+ return pcap_dump_open(p, fname);
+}
+
+void CDECL wine_pcap_dump(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
+{
+ return pcap_dump(user, h, sp);
+}
diff --git a/dlls/wpcap/wpcap.spec b/dlls/wpcap/wpcap.spec
index 0e1e208..cf2ed43 100644
--- a/dlls/wpcap/wpcap.spec
+++ b/dlls/wpcap/wpcap.spec
@@ -16,12 +16,12 @@
@ cdecl pcap_datalink_val_to_description(long) wine_pcap_datalink_val_to_description
@ cdecl pcap_datalink_val_to_name(long) wine_pcap_datalink_val_to_name
@ cdecl pcap_dispatch(ptr long ptr ptr) wine_pcap_dispatch
-@ stub pcap_dump
+@ cdecl pcap_dump(ptr ptr str) wine_pcap_dump
@ stub pcap_dump_close
@ stub pcap_dump_file
@ stub pcap_dump_flush
@ stub pcap_dump_ftell
-@ stub pcap_dump_open
+@ cdecl pcap_dump_open(ptr str) wine_pcap_dump_open
@ stub pcap_file
@ stub pcap_fileno
@ cdecl pcap_findalldevs(ptr ptr) wine_pcap_findalldevs
--
2.6.4

View File

@ -0,0 +1,57 @@
From b20a7a0ed29c40ad50c0e43b1f3d1cf3558f492e Mon Sep 17 00:00:00 2001
From: Jianqiu Zhang <zhangjianqiu_133@yeah.net>
Date: Thu, 7 Jan 2016 16:34:17 +0800
Subject: wpcap: Fix crash on pcap_loop
Signed-off-by: Jianqiu Zhang <zhangjianqiu_133@yeah.net>
---
dlls/wpcap/wpcap.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/dlls/wpcap/wpcap.c b/dlls/wpcap/wpcap.c
index da911c7..44e8c2a 100644
--- a/dlls/wpcap/wpcap.c
+++ b/dlls/wpcap/wpcap.c
@@ -95,7 +95,6 @@ static void pcap_handler_callback(u_char *user_data, const struct pcap_pkthdr *h
TRACE("(%p %p %p)\n", user_data, h, p);
pcb = (PCAP_HANDLER_CALLBACK *)user_data;
pcb->pfn_cb(pcb->user_data, h, p);
- HeapFree(GetProcessHeap(), 0, pcb);
TRACE("Callback COMPLETED\n");
}
@@ -108,10 +107,14 @@ int CDECL wine_pcap_dispatch(pcap_t *p, int cnt,
if (callback)
{
PCAP_HANDLER_CALLBACK *pcb;
+ int res;
+
pcb = HeapAlloc(GetProcessHeap(), 0, sizeof(PCAP_HANDLER_CALLBACK));
pcb->pfn_cb = callback;
pcb->user_data = user;
- return pcap_dispatch(p, cnt, pcap_handler_callback, (unsigned char*)pcb);
+ res = pcap_dispatch(p, cnt, pcap_handler_callback, (unsigned char *)pcb);
+ HeapFree(GetProcessHeap(), 0, pcb);
+ return res;
}
return pcap_dispatch(p, cnt, NULL, user);
@@ -201,10 +204,14 @@ int CDECL wine_pcap_loop(pcap_t *p, int cnt,
if (callback)
{
PCAP_HANDLER_CALLBACK *pcb;
+ int res;
+
pcb = HeapAlloc(GetProcessHeap(), 0, sizeof(PCAP_HANDLER_CALLBACK));
pcb->pfn_cb = callback;
pcb->user_data = user;
- return pcap_loop(p, cnt, pcap_handler_callback, (unsigned char*)pcb);
+ res = pcap_loop(p, cnt, pcap_handler_callback, (unsigned char *)pcb);
+ HeapFree(GetProcessHeap(), 0, pcb);
+ return res;
}
return pcap_loop(p, cnt, NULL, user);
--
2.6.4

View File

@ -0,0 +1,2 @@
Fixes: Implement pcap_dump_open and pcap_dump
Fixes: Fix possible crash in pcap_loop