]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
l2_packet_ndis: Fix overlapped write not to corrupt stack
authorJouni Malinen <j@w1.fi>
Thu, 2 Sep 2010 10:23:14 +0000 (13:23 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 2 Sep 2010 10:23:14 +0000 (13:23 +0300)
When using overlapped write, we must have the provided memory
areas available during the operation and cannot just use stack
unless we wait for the completion within the function. In the case
of TX here, we can easily wait for the completion since it is likely
to happen immediately. In addition, this provides more reliable
success/failure return value for l2_packet_send(). [Bug 328]

src/l2_packet/l2_packet_ndis.c

index 7de58808d63c506cbaea1532e7e423d47daf1997..6ce29aa20ec93cd66f2791e7ad8120f6acbd3a4e 100644 (file)
@@ -137,11 +137,17 @@ int l2_packet_send(struct l2_packet_data *l2, const u8 *dst_addr, u16 proto,
                DWORD err = GetLastError();
 #ifndef _WIN32_WCE
                if (err == ERROR_IO_PENDING) {
-                       /* For now, just assume that the packet will be sent in
-                        * time before the next write happens. This could be
-                        * cleaned up at some point to actually wait for
-                        * completion before starting new writes.
-                        */
+                       wpa_printf(MSG_DEBUG, "L2(NDISUIO): Wait for pending "
+                                  "write to complete");
+                       res = GetOverlappedResult(
+                               driver_ndis_get_ndisuio_handle(), &overlapped,
+                               &written, TRUE);
+                       if (!res) {
+                               wpa_printf(MSG_DEBUG, "L2(NDISUIO): "
+                                          "GetOverlappedResult failed: %d",
+                                          (int) GetLastError());
+                               return -1;
+                       }
                        return 0;
                }
 #endif /* _WIN32_WCE */