Skip to content

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

Open
JOsee321 wants to merge 1 commit into
openmultiplayer:masterfrom
JOsee321:fix/query-panic-and-stream-checksum
Open

fix(backend): prevent query panic on short packets, optimize IP resolution, and stream checksum calculation#428
JOsee321 wants to merge 1 commit into
openmultiplayer:masterfrom
JOsee321:fix/query-panic-and-stream-checksum

Conversation

@JOsee321

Copy link
Copy Markdown

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.

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.

1 participant