Skip to contentSkip to conversation

wintun: fix ringbuffer registration call

PATCH Lev Stipakov 1 participant 2 messages Nov 19, 2019 – Nov 20, 2019

lore
Share & tools
lore
#0 lore raw

From: Lev Stipakov <[email protected]...>

As MS documentation says:

Quoted 1 line

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
---
 src/openvpn/ring_buffer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
src/openvpn/ring_buffer.c +3 -1
index 482e3336..d384f497 100644
@@ -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;
 }
Signature · 1 line
2.17.1
#1 lore raw

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 ([email protected]...) kirjoitti:

Quoted 43 lines

From: Lev Stipakov <[email protected]...>

As MS documentation says:

Quoted 1 line

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
---
 src/openvpn/ring_buffer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
src/openvpn/ring_buffer.c +3 -1
index 482e3336..d384f497 100644
@@ -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

Signature · 1 line
-Lev