Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Memory access violation on high data rates #5

Closed
TylerBird opened this issue Oct 13, 2020 · 0 comments · Fixed by TylerBird/ESP32_I2C_Slave#1 or #6
Closed

Memory access violation on high data rates #5

TylerBird opened this issue Oct 13, 2020 · 0 comments · Fixed by TylerBird/ESP32_I2C_Slave#1 or #6

Comments

@TylerBird
Copy link
Contributor

TylerBird commented Oct 13, 2020

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))

I will create a pull request with this fix.

TylerBird added a commit to TylerBird/ESP32_I2C_Slave that referenced this issue Oct 13, 2020
add boundary check for array index
fixes gutierrezps#5
gutierrezps pushed a commit that referenced this issue Nov 12, 2020
* Update WireSlaveRequest.cpp

add boundary check for array index
fixes #5
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant