[Openvpn-devel,8/7] wintun: fix ringbuffer registration call

Message ID 20191119190951.87-1-lstipakov@gmail.com
State Superseded
Headers show
Series
  • Untitled series #603
Related show

Commit Message

Lev Stipakov Nov. 19, 2019, 7:09 p.m.
From: Lev Stipakov <lev@openvpn.net>

As MS documentation says:

 > If lpOverlapped is NULL, lpBytesReturned cannot be NULL

While on Windows 10 passing NULL works by accident,
on Windows 7 it crashes.

Reported-by: kitsune1
Signed-off-by: Lev Stipakov <lev@openvpn.net>
---
 src/openvpn/ring_buffer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Lev Stipakov Nov. 20, 2019, 3:09 p.m. | #1
Please disregard this patch - I made it as a fix to
"wintun: ring buffers based I/O", which was resent as v5.

ti 19. marrask. 2019 klo 21.10 Lev Stipakov (lstipakov@gmail.com) kirjoitti:

> From: Lev Stipakov <lev@openvpn.net>
>
> As MS documentation says:
>
>  > If lpOverlapped is NULL, lpBytesReturned cannot be NULL
>
> While on Windows 10 passing NULL works by accident,
> on Windows 7 it crashes.
>
> Reported-by: kitsune1
> Signed-off-by: Lev Stipakov <lev@openvpn.net>
> ---
>  src/openvpn/ring_buffer.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/openvpn/ring_buffer.c b/src/openvpn/ring_buffer.c
> index 482e3336..d384f497 100644
> --- a/src/openvpn/ring_buffer.c
> +++ b/src/openvpn/ring_buffer.c
> @@ -35,6 +35,7 @@ register_ring_buffers(HANDLE device,
>  {
>      struct tun_register_rings rr;
>      BOOL res;
> +    DWORD bytes_returned;
>
>      ZeroMemory(&rr, sizeof(rr));
>
> @@ -46,7 +47,8 @@ register_ring_buffers(HANDLE device,
>      rr.receive.ring_size = sizeof(receive_ring->data);
>      rr.receive.tail_moved = receive_tail_moved;
>
> -    res = DeviceIoControl(device, TUN_IOCTL_REGISTER_RINGS, &rr,
> sizeof(rr), NULL, 0, NULL, NULL);
> +    res = DeviceIoControl(device, TUN_IOCTL_REGISTER_RINGS, &rr,
> sizeof(rr),
> +        NULL, 0, &bytes_returned, NULL);
>
>      return res == TRUE;
>  }
> --
> 2.17.1
>
>

Patch

diff --git a/src/openvpn/ring_buffer.c b/src/openvpn/ring_buffer.c
index 482e3336..d384f497 100644
--- a/src/openvpn/ring_buffer.c
+++ b/src/openvpn/ring_buffer.c
@@ -35,6 +35,7 @@  register_ring_buffers(HANDLE device,
 {
     struct tun_register_rings rr;
     BOOL res;
+    DWORD bytes_returned;
 
     ZeroMemory(&rr, sizeof(rr));
 
@@ -46,7 +47,8 @@  register_ring_buffers(HANDLE device,
     rr.receive.ring_size = sizeof(receive_ring->data);
     rr.receive.tail_moved = receive_tail_moved;
 
-    res = DeviceIoControl(device, TUN_IOCTL_REGISTER_RINGS, &rr, sizeof(rr), NULL, 0, NULL, NULL);
+    res = DeviceIoControl(device, TUN_IOCTL_REGISTER_RINGS, &rr, sizeof(rr),
+        NULL, 0, &bytes_returned, NULL);
 
     return res == TRUE;
 }