Skip to content

Use fail-safe ReadBit overload in join packet parser#4910

Open
Dutchman101 wants to merge 1 commit intomultitheftauto:masterfrom
Dutchman101:readbit-overload
Open

Use fail-safe ReadBit overload in join packet parser#4910
Dutchman101 wants to merge 1 commit intomultitheftauto:masterfrom
Dutchman101:readbit-overload

Conversation

@Dutchman101
Copy link
Copy Markdown
Member

@Dutchman101 Dutchman101 commented May 9, 2026

Use fail-safe ReadBit overload in join packet parser

The no-arg ReadBit() returns the bit value, not a success indicator - on
bitstream exhaustion it silently returns false, not distinguishable from
reading a 0 bit. Switch to the ReadBit(bool&) overload from bitstream.h
which wraps ReadBits internally and properly returns false on exhaustion.

Now, the ReadBit is consistent with every other read in the function, (they all early-return on failure)

Scenario where it (pre-PR) would be a problem, and how:

If the bitstream is exhausted:

  1. ReadBit() returns false - indistinguishable from "the bit was 0"
  2. The parser continues with m_bOptionalUpdateInfoRequired = false instead of failing
  3. Subsequent reads operate on garbage/out-of-bounds data, and that will cause unexpected behavior and real problems.

@Dutchman101
Copy link
Copy Markdown
Member Author

I've updated the desc with a plausible bug scenario

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