On 31/01/2023 13:25, Lev Stipakov wrote:
From: Lev Stipakov <l...@openvpn.net>

WinAPI uses __stdcall calling convention on x86. Wrong
calling convention causes UB, which in this case breaks
dco-win functionality.

Signed-off-by: Lev Stipakov <l...@openvpn.net>
---
  src/openvpn/dco_win.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/openvpn/dco_win.c b/src/openvpn/dco_win.c
index 7594024c..da1e1fbc 100644
--- a/src/openvpn/dco_win.c
+++ b/src/openvpn/dco_win.c
@@ -110,7 +110,7 @@ dco_connect_wait(HANDLE handle, OVERLAPPED *ov, int 
timeout, struct signal_info
  {
      volatile int *signal_received = &sig_info->signal_received;
      /* GetOverlappedResultEx is available starting from Windows 8 */
-    typedef BOOL (*get_overlapped_result_ex_t) (HANDLE, LPOVERLAPPED, LPDWORD, 
DWORD, BOOL);
+    typedef BOOL (__stdcall *get_overlapped_result_ex_t) (HANDLE, 
LPOVERLAPPED, LPDWORD, DWORD, BOOL);

Wouldn't it be better to use the WINAPI Macro here, so it's the right calling convention no matter the arch?

Not sure what header it's defined in, but a quick search suggests it comes from minwindef.h.

      get_overlapped_result_ex_t get_overlapped_result_ex =
          
(get_overlapped_result_ex_t)GetProcAddress(GetModuleHandle("Kernel32.dll"),
                                                     "GetOverlappedResultEx");


_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to