You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Harden Win32 FFI boundary and fix safety/correctness issues (0.7.0) (#39)
* feat!: harden Win32 FFI boundary for 0.7.0
Harden the Win32/driver boundary and bump the crate to 0.7.0.
Remove `Clone` from `Ndisapi` to prevent double-closing the owned driver handle, and mark generic `ndis_get_request` / `ndis_set_request` as `unsafe` because the driver reads and writes raw `T` bytes.
Fix IPv6 sockaddr truncation, uninitialized storage reads, async event lost-wakeup and teardown races, partial-construction handle leaks, registry UB/leaks, UTF-16 friendly-name writes, frame-length clamping, IPv4 byte-layout conversion, masked per-entry errors, adapter-count/name handling, and async batch-send return counts.
Also clean up docs, comments, formatting, and clippy warnings.
notif:Win32EventStream::new(event_handle)?,// Creating a new Win32EventStream with the event handle.
100
+
notif,
88
101
})
89
102
}
90
103
@@ -227,7 +240,7 @@ impl AsyncNdisapiAdapter {
227
240
/// # Arguments
228
241
///
229
242
/// * `packet` - An `IntermediateBuffer` that will be encapsulated in an `EthPacket`
230
-
/// representing the Ethernet packet to be sent.
243
+
/// representing the Ethernet packet to be sent.
231
244
///
232
245
/// # Safety
233
246
///
@@ -277,7 +290,7 @@ impl AsyncNdisapiAdapter {
277
290
///
278
291
/// # Returns
279
292
///
280
-
/// On successful operation, this function returns an `Ok(usize)` that represents the number of packets successfully sent to the network adapter. If the operation fails, an error is returned.
293
+
/// On successful operation, this function returns an `Ok(usize)` with the number of packets that were submitted to the driver for sending. If the operation fails, an error is returned.
// The send IOCTL takes no output buffer, so the driver never writes back the
305
+
// `packet_success` counter (unlike the read path); it would always read as 0 here.
306
+
// Report the number of packets submitted in the request instead, which is the
307
+
// meaningful value on the success path.
308
+
self.driver
309
+
.send_packets_to_adapter(&request)
310
+
.map(|_| request.get_packet_number()asusize)
294
311
}
295
312
296
313
/// Sends an Ethernet packet upwards through the network stack to the Microsoft TCP/IP protocol driver.
@@ -346,7 +363,7 @@ impl AsyncNdisapiAdapter {
346
363
///
347
364
/// # Returns
348
365
///
349
-
/// On successful operation, this function returns `Ok(usize)`, where `usize` is the number of packets sent. If the operation fails, an error is returned.
366
+
/// On successful operation, this function returns `Ok(usize)`, where `usize` is the number of packets submitted to the driver for sending. If the operation fails, an error is returned.
0 commit comments