Thank you for your library.
I used it in a project and stumbled upon an issue on high data rates.
I found two problems in the WireSlaveRequest.cpp where memory is accessed in an array without range checking the index.
I solved the problem by changing the line while (unpacker.available()) in the bool WireSlaveRequest::request(uint8_t address) function to while ((unpacker.available()) && (rxIndex_ < UNPACKER_BUFFER_LENGTH))
and line if (lastStatus_ == PACKET_READ && rxIndex_ < rxLength_) in the int WireSlaveRequest::read() function to if (lastStatus_ == PACKET_READ && rxIndex_ < rxLength_ && (rxIndex_ < UNPACKER_BUFFER_LENGTH))
Thank you for your library. I used it in a project and stumbled upon an issue on high data rates. I found two problems in the
WireSlaveRequest.cpp
where memory is accessed in an array without range checking the index.I solved the problem by changing the line
while (unpacker.available())
in thebool WireSlaveRequest::request(uint8_t address)
function towhile ((unpacker.available()) && (rxIndex_ < UNPACKER_BUFFER_LENGTH))
and lineif (lastStatus_ == PACKET_READ && rxIndex_ < rxLength_)
in theint WireSlaveRequest::read()
function toif (lastStatus_ == PACKET_READ && rxIndex_ < rxLength_ && (rxIndex_ < UNPACKER_BUFFER_LENGTH))
I will create a pull request with this fix.