Skip to content

Conversation

@arche8
Copy link

@arche8 arche8 commented Nov 10, 2025

Bug Description

When processing oversized SYSEX messages, buffer overflow occurs due to missing bounds checks in processSysexMessage() and decodeByteStream(). For example, when sysexBytesRead = 148 but dataBufferSize = 64, the system attempts to process 147 bytes of data in a 64-byte buffer(https://github.com/firmata/arduino/blob/main/FirmataParser.cpp#L448). This causes memory corruption by:

  • Writing beyond dataBuffer boundaries in decodeByteStream()
  • Overwriting the dataBuffer pointer itself through out-of-bounds writes
  • Causing system crashes when the corrupted dataBuffer pointer is dereferenced

Proposed Fix

Ensure decodeByteStream() only processes data that actually exists within dataBuffer bounds by using min(sysexBytesRead - offset, dataBufferSize - offset) in processSysexMessage function.

@arche8 arche8 marked this pull request as ready for review November 10, 2025 13:00
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.

1 participant