Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix binary_span_reader_writer.h (off-by-one error) #3230

Merged
merged 1 commit into from
Jun 23, 2024

Conversation

TheUbMunster
Copy link
Contributor

Found what I believe to be an off-by-one error while debugging a PINE api user.

When stack trace is:

BinarySpanReader::Read(void* buf, unsigned __int64 size) (the function I believe that contains the error)
BinarySpanReader::ReadT()
BinarySpanReader::ReadU32() <-- called by switch case no. MsgRead64: "const PhysicalMemoryAddress addr = rdbuf.ReadU32();"
PINESocket::HandleCommand(PINEServer::IPCCommand command, BinarySpanReader rdbuf)
PINESocket::ProcessCommandsInBuffer()
...

and m_pos == 0 && size == 4 && m_buf.size() == 4 (large enough to contain a u32)
the comparison fails, even though I think it should succeed and pull out a u32, followed by moving m_pos forward 4 bytes.

Feel free to contact me if you require further details.

Also, If I'm wrong or making an incorrect assumption, please let me know!

@TheUbMunster TheUbMunster changed the title Update binary_span_reader_writer.h Fix binary_span_reader_writer.h (off-by-one error) Jun 19, 2024
@stenzek
Copy link
Owner

stenzek commented Jun 23, 2024

Good catch, classic off by one when I inverted the condition.

@stenzek stenzek merged commit 4827e54 into stenzek:master Jun 23, 2024
@TheUbMunster TheUbMunster deleted the patch-1 branch June 23, 2024 05:48
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