Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix buffer-overflow assigning global Wire instances. #317

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

Merged
facchinm merged 1 commit into main from fix-buffer-overflow
May 15, 2024

Conversation

Copy link
Contributor

@aentinger aentinger commented May 15, 2024

Two pointer arrays declared, which contain pointers to the global SCI/I2C Wire instances: "g_SCIWires" and "g_I2CWires". Since there's a different number of SCI vs pure I2C "I2C" interfaces those buffers are of different size. Due to a typo the constant declaring the size of the pointe rarray for "g_SCIWires" ("TWOWIRE_MAX_SCI_CHANNELS") was used to define the size of "g_I2CWires" and vice versa. This had the result that on Portenta C33, íf you were calling "TwoWire::_begin()" for "Wire3" (which has channel "3") a buffer overflow occurs and random memory is overwritten.

pennam, facchinm, sebromero, and aliphys reacted with rocket emoji
Two pointer arrays declared, which contain pointers to the global SCI/I2C Wire instances: "g_SCIWires" and "g_I2CWires". Since there's a different number of SCI vs pure I2C "I2C" interfaces those buffers are of different size. Due to a typo the constant declaring the size of the pointe rarray for "g_SCIWires" ("TWOWIRE_MAX_SCI_CHANNELS") was used to define the size of "g_I2CWires" and vice versa. This had the result that on Portenta C33, íf you were calling "TwoWire::_begin()" for "Wire3" (which has channel "3") a buffer overflow occurs and random memory is overwritten.
@aentinger aentinger added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels May 15, 2024
@aentinger aentinger self-assigned this May 15, 2024
@facchinm facchinm merged commit 9029d7d into main May 15, 2024
@facchinm facchinm deleted the fix-buffer-overflow branch May 15, 2024 07:16
Copy link
Contributor

Brilliant @aentinger ! Thanks a lot for your help with this 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@facchinm facchinm Awaiting requested review from facchinm

@maidnl maidnl Awaiting requested review from maidnl

Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /