Add check bytes for voice packet#4728
Conversation
|
|
||
| if (BitStream.Read(voiceBufferLength) && voiceBufferLength <= m_voiceBuffer.capacity()) | ||
| { | ||
| if (!BitStream.CanReadNumberOfBytes(voiceBufferLength)) |
There was a problem hiding this comment.
This check is actually unnecessary and essentially redundant. The logic drops invalid packets in
if (BitStream.Read(voiceBufferLength) && voiceBufferLength <= m_voiceBuffer.capacity())
There was a problem hiding this comment.
Will it handle a scheme like this?
Write(2048);
Write("", 0);I doubt it.
There was a problem hiding this comment.
Yes, it does. If you attempt to read more from the BitStream than is available, it simply returns false.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
If you call resize when the buffer is already that size, it doesn't consume significant CPU time, as no reallocations occur..
There was a problem hiding this comment.
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.
No description provided.