Skip to content

Add check bytes for voice packet#4728

Closed
G-Moris wants to merge 2 commits intomultitheftauto:masterfrom
G-Moris:add-check1-voice
Closed

Add check bytes for voice packet#4728
G-Moris wants to merge 2 commits intomultitheftauto:masterfrom
G-Moris:add-check1-voice

Conversation

@G-Moris
Copy link
Contributor

@G-Moris G-Moris commented Feb 26, 2026

No description provided.

@G-Moris G-Moris requested a review from a team as a code owner February 26, 2026 05:09

if (BitStream.Read(voiceBufferLength) && voiceBufferLength <= m_voiceBuffer.capacity())
{
if (!BitStream.CanReadNumberOfBytes(voiceBufferLength))
Copy link
Contributor

Choose a reason for hiding this comment

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

This check is actually unnecessary and essentially redundant. The logic drops invalid packets in
if (BitStream.Read(voiceBufferLength) && voiceBufferLength <= m_voiceBuffer.capacity())

Copy link
Contributor Author

@G-Moris G-Moris Feb 26, 2026

Choose a reason for hiding this comment

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

Will it handle a scheme like this?

Write(2048);
Write("", 0);

I doubt it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it does. If you attempt to read more from the BitStream than is available, it simply returns false.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it does. If you attempt to read more from the BitStream than is available, it simply returns false.

Calling resize is more expensive than performing a single check.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you call resize when the buffer is already that size, it doesn't consume significant CPU time, as no reallocations occur..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you call resize when the buffer is already that size, it doesn't consume significant CPU time, as no reallocations occur..

If you're that confident about it - good.

@G-Moris G-Moris closed this Feb 26, 2026
@G-Moris G-Moris deleted the add-check1-voice branch February 26, 2026 06:03
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