Skip to content

Validate sub-structure reads and initialize SUnoccupiedVehicleSync - #5565

Open
DrWellsy wants to merge 1 commit into
multitheftauto:masterfrom
DrWellsy:fix/unoccupied-vehicle-sync-validation
Open

DrWellsy wants to merge 1 commit into
multitheftauto:masterfrom
DrWellsy:fix/unoccupied-vehicle-sync-validation

Conversation

@DrWellsy

Copy link
Copy Markdown

Summary

Check the return value of every sub-structure read (SPositionSync, SRotationDegreesSync, SVelocitySync, SVehicleHealthSync, and trailer ElementID) inside SUnoccupiedVehicleSync::Read, reject failed entries in CUnoccupiedVehicleSyncPacket::Read instead of continuing on out-of-sync streams, and value-initialize SUnoccupiedVehicleSync::data in its constructor.

Motivation

SUnoccupiedVehicleSync::Read previously discarded sub-structure Read() failures, so out-of-bounds/non-finite positions caught by SPositionSync, non-finite velocities caught by SVelocitySync, or truncated fields still propagated as valid sync updates. The constructor's 1-byte zeroing (*((char*)&data) = 0) also left the 9th bitfield bit (bIsInWater) and scalar fields uninitialized.

Test plan

Built Deathmatch and Tests_Client (Release Win32), verified formatting with clang-format, and ran Tests_Client.exe (318 tests passing, including 5 new SUnoccupiedVehicleSync unit tests covering initialization, full round-trips, out-of-bounds Z position, NaN velocity, and truncated streams).

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

SUnoccupiedVehicleSync::Read previously ignored return values from SPositionSync, SRotationDegreesSync, SVelocitySync, SVehicleHealthSync, and trailer ID reads, allowing out-of-bounds positions, non-finite velocities, or truncated fields to pass as valid.

Validate each read in SUnoccupiedVehicleSync::Read and reject invalid entries in CUnoccupiedVehicleSyncPacket::Read instead of continuing on corrupted data. Value-initialize data in SUnoccupiedVehicleSync's constructor as well (the previous 1-byte write missed the 9th bitfield bit bIsInWater and remaining scalar fields).

Add unit tests in SyncVehicle_Tests.cpp covering initialization, full round-trips, out-of-bounds positions, non-finite velocities, and truncated streams.
Copilot AI balanced review requested due to automatic review settings November 18, 2026 18:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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