ModernUO/Projects/Server/Network
Kamron Batman ee600d02ac
fix(network): stop silently dropping packets when the send buffer is full
NetState.Send had three failure modes once the send buffer filled, none of
them visible:

  - No writable space: GetSendBuffer returned false and the packet was
    dropped with no log and no disconnect. The client stayed connected
    while quietly missing game state.

  - Some space but not enough: NetworkCompression.Compress hit its guard
    and returned 0, so CommitWrite(0) ran and the packet was dropped the
    same way.

  - One to three bytes writable: Compress computes
    safeOutputLength = (nuint)output.Length - 4, which underflows for
    those sizes. The hot loop's bounds check never trips and it writes
    past the span, corrupting the in-flight region of the ring buffer.
    Reachable because callers only check for non-zero space.

Compress now refuses an output too small to bound, and Send reports
exhaustion instead of dropping: it logs and disconnects with the bytes
needed, writable, awaiting acknowledgement, and total capacity. Those
numbers separate a slow client holding the buffer from a buffer genuinely
too small for the shard, which is the case that warrants raising
network.sendBufferSize.

Tests cover the underflow via sentinel bytes around the output window and
were confirmed to fail without the guard.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-27 22:55:37 -07:00
..
Bans feat(network): pluggable connection filters; file blocklist + contribute-first CrowdSec (#2542) 2026-07-25 11:59:37 -07:00
Encryption fix: Fixes encryption support for pre-6.0.5 clients (#2365) 2026-03-12 21:59:01 -07:00
NetState fix(network): stop silently dropping packets when the send buffer is full 2026-07-27 22:55:37 -07:00
Packets refactor: decompose mobile/corpse hair, delete VirtualHairInfo, fix removal serial (#2462) (#2463) 2026-06-06 14:33:28 -07:00
ConnectionFilters.cs feat(network): pluggable connection filters; file blocklist + contribute-first CrowdSec (#2542) 2026-07-25 11:59:37 -07:00
EncodedPacketHandler.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
EncodedReader.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
IConnectionFilter.cs feat(network): pluggable connection filters; file blocklist + contribute-first CrowdSec (#2542) 2026-07-25 11:59:37 -07:00
IPRateLimiter.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
MovementThrottle.cs feat: Adds robust speed hack detection and movement throttling (#2266) 2026-03-07 11:44:37 -08:00
NetworkCompression.cs fix(network): stop silently dropping packets when the send buffer is full 2026-07-27 22:55:37 -07:00
PacketHandler.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
PacketUtilities.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
PingServer.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
ServerInfo.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
SocketHelper.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00