Skip to content

fix(backend): prevent query panic on short packets, optimize IP resolution, and stream checksum calculation - #428

Merged
AmyrAhmady merged 3 commits into
openmultiplayer:masterfrom
JOsee321:fix/query-panic-and-stream-checksum
Oct 10, 2026
Merged

AmyrAhmady merged 3 commits into
openmultiplayer:masterfrom
JOsee321:fix/query-panic-and-stream-checksum

Conversation

@JOsee321

Copy link
Copy Markdown
Contributor

Summary of Changes

  1. Fix Slice Out-of-Bounds Panic in UDP Query (query.rs):

    • Added a minimum length check (amt < 11) before slicing buffer headers. Prevents unexpected thread panic when receiving truncated or corrupted UDP packets.
  2. Optimize IP Parsing & Eliminate Repeated Regex Compilation (query.rs):

    • Replaced on-the-fly Regex::new compilation on every query with native standard library addr.parse::<Ipv4Addr>() and socket_address.ip() matching.
    • Eliminates redundant CPU/heap overhead during high-frequency server polling.
  3. Streamed MD5 Checksum Calculation (commands.rs):

    • Replaced f.read_to_end(&mut contents) with a 64KB chunked buffer stream feeding into md5::Context.
    • Prevents memory exhaustion / Out-Of-Memory (OOM) crashes on 32-bit Windows builds when calculating checksums for large archive/game files.

Testing

  • Verified clean compilation and correct error handling on invalid/short buffers.
  • Verified MD5 checksum output consistency with buffered streaming.

@AmyrAhmady
AmyrAhmady merged commit 521bc01 into openmultiplayer:master Oct 10, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants