15 Commits
Author SHA1 Message Date
Johannes Weiss ea000751b1 Reject too-small IPv4 packets in the PCAP parser test helper (#320)
### Motivation:

The readTCPIPv4 helper subtracted 20 from the IPv4 total length field in
UInt16 space before validating it. A total length below the header size
wraps around and traps with an arithmetic overflow.

A TCP/IPv4 packet is always at least 40 bytes (a 20 byte IPv4 header
plus a 20 byte TCP header), so a smaller total length is an illegal
packet that no further data can complete. Validate the total length
alongside the version and protocol checks and throw when it is too
small, then slice the payload. A regression test covers the lengths that
previously trapped.

These helpers only ever parse pcaps that WritePCAPHandler wrote, which
are always well formed, so the bug was dormant here. It becomes a real
crash when the helpers are reused to parse arbitrary captures.

### Modifications:

- Implement the check

### Result:

- More correct code, even though it's just a test helper
2026-07-17 10:59:41 +00:00
George Barnett 20c59b2d64 Strict concurrency for NIOExtras and NIOExtrasTests (#254) 2025-03-31 11:53:06 +01:00
Honza Dvorsky ae4d6b4b9a Add a missing import to CNIOLinux (#251)
### Motivation:

Stricter import rules mean that using the `sin_addr` property on Linux
requires the explicit CNIOLinux import.

### Modifications:

Added the missing import.

### Result:

Fixes a CI diagnostic.
2025-03-11 12:10:01 +00:00
Marc Prud'hommeauxandGeorge Barnett aa0d902637 Android support (#244)
Add Android support

### Motivation:

Support the Android platform.

### Modifications:

Add Android imports and fix the default temporary directory to be
correct for the OS.

### Result:

The package will build and test on Android.

---------

Co-authored-by: George Barnett <gbarnett@apple.com>
2025-01-14 16:48:42 +00:00
George Barnett 74a143a79f Fix warnings (#245)
Motivation:

The latest NIO release deprecated a number of APIs and added more
Sendable contraints.

Modifications:

- Use sync APIs where possible
- Use `_deprecated` but not `@deprecated` NIOFileHandle API
- Stop using NIOAny

Result:

No warnings
2025-01-14 11:24:08 +00:00
Rick Newton-Rogers 3f776e9aaf Migrate CI to use GitHub Actions. (#234)
### Motivation:

To migrate to GitHub actions and centralised infrastructure.

### Modifications:

Changes of note:
* Adopt swift-format using rules from SwiftNIO
* Remove scripts and docker files which are no longer needed

### Result:

Feature parity with old CI.
2024-10-28 14:00:57 +00:00
carolinacass 91dd2d61fb Use #fileID/#filePath instead of #file (#184)
Motivation:

Modifications:

Changed #file to #filePath or #fileID depending on situation
2022-10-28 13:56:39 +01:00
Cory Benfield d66ae0557e Clean up imports and dependencies. (#144)
Motivation:

With NIO 2.32.0 we broke the core NIO module up into modules that split
apart the POSIX layer and the core abstractions. As a result, this
package no longer needs to express a hard dependency on the POSIX layer.

Modifications:

- Rewrote imports of NIO to NIOCore.
- Added NIOEmbedded and NIOPosix imports where necessary in tests.
- Extended soundness script to detect NIO imports.
- Note that the main modules still depend on NIO, which is necessary
    for backwards-compatibility reasons. This dependency is unused.

Result:

No need to use NIOPosix.
2021-09-14 16:30:39 +01:00
David Evans 6740bf98c2 Silence #file warnings (#97)
* Wrap in parentheses

* Revert previous changes
2020-07-24 16:54:32 +01:00
David Evans 1cb9e9e24b Fix #file warnings (#96)
* Fix #file warnings
2020-07-24 14:54:39 +01:00
Johannes Weiss 7cd24c0efc WritePCAPHandler: support logging more than 4GiB of data (#85)
Motivation:

Previously, WritePCAPHandler would crash if more than 4GiB of data were
either received or sent through the same instance of the
WritePCAPHandler because of a UInt32 overflow representing the TCP
sequence/ACK numbers.

Modifications:

Make TCP sequence/ACK numbers wrap around correctly.

Result:

- now you can send/receive up to 16 EiB of data :P.
- fixes rdar://61887658
2020-05-18 11:37:20 +01:00
Johannes Weiss a98eabea3f NIOWritePCAPHandler: make pcap issuing configurable (#75) 2020-01-20 15:15:36 +00:00
Johannes Weiss 698f4f7396 WritePCAPHandler: write outbound data on flush not write (#74) 2020-01-17 14:12:34 +00:00
Johannes Weiss 64c4d22ba5 follow general parser guidelines, even in tests (#62) 2019-10-25 01:30:08 -07:00
Johannes Weiss 96e8335180 write PCAP handler (#46)
Motivation:

Especially with TLS but also without, in real production environments it
can be handy to be able to write pcap files from NIO directly.

Modifications:

add a ChannelHandler that can write a PCAP trace from what's going on in
the ChannelPipeline.

Result:

easier debugging in production
2019-04-12 15:08:10 +01:00