-
Notifications
You must be signed in to change notification settings - Fork 21
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
I2C driver causing segmentation fault in onion-i2c.c #20
Comments
Yes, we had seen this as well and fixed it in the Did it now, will release an updated package soon! |
Is this true? Seems like it was never merged. There are still offending lines: https://github.com/OnionIoT/i2c-exp-driver/blob/master/src/lib/onion-i2c.c#L313 Re-discovered these while trying to write a I2C device driver and wondering why my programm keeps crashing with a corrupted stack. |
The In any case, it's fixed now and part of the v0.7 libonioni2c release. Please try it out and let me know if you have any issues. |
The code looks good now. I was able to remove my workarounds for library bugs and it does work with the newest version! Issue can be closed IMO. |
When performing reads and writes the buffer is often cleared by performing a memset. the driver assumes a buffer of 32 bytes and always performs
memset( buffer, 0, I2C_BUFFER_SIZE );
If the user supplies a smaller or bigger buffer, this could not have the intended effect. For a smaller buffer this can overwrite memory past the end of the supplied buffer, thus causing a segmentation fault.
Rather use the nbytes parameter and only perform a memset on the length of the buffer provided.
The text was updated successfully, but these errors were encountered: