Comments (4)
(thanks for pointing me to this from the Omega forums)
good catch on this increasing buffer size, but, i think it doesn't affect the intended functionality once in _i2c_writeBuffer. So, inside of i2c_writeBuffer, in your example, size
was: 3 | is: 4 and bufferNew
is 5. Once passed to _i2c_writeBuffer
, the actual write
command still uses size
(which is 4), so you'll be writing the address + 3 bytes. Only consequence I see, is that you're wasting the time and space to store garbage in bufferNew[5] (or am I wrong?)
// generic function to write a buffer to the i2c bus
int _i2c_writeBuffer(int devNum, int devAddr, uint8_t *buffer, int size)
{
int status;
int fd, index;
......
// write to the i2c device
status = write(fd, buffer, size);
..........
return (status);
}`
from i2c-exp-driver.
It will correctly write the write number of bytes to the I2C device (address + initially given buffer), right. (However bufferNew
has 4 byte allocated, not 5, and the overwritten index is bufferNew[4]
, the 5th byte from the start, but the rest is correct)
However the damage is already done after the memcpy
beyond the boundaries of bufferNew
because the allocated / malloc()
ed space just isn't big enough (by 1 byte). This will cause an overwrite into some other memory structure on the heap or a heap information block, which can cause subsequent program failure.
Memory / heap corruption might even be exploitable in special settings, i.e. be used for a system takeover by attacking the programs using this I2C library (https://googleprojectzero.blogspot.de/2015/06/what-is-good-memory-corruption.html).
from i2c-exp-driver.
@maxgerhardt yep, you were absolutely correct, we were copying by the incremented size
instead of the actual size.
We've released v0.7 of libonioni2c, please try it out and let us know if there's any issues.
from i2c-exp-driver.
Yep, this off-by-one was fixed.
from i2c-exp-driver.
Related Issues (17)
- Output Verbosity HOT 1
- oled-exp draw command fills the screen with random pixels in the undefined zones.
- Omega I2C driver misses reading without defining register address HOT 2
- Change I2C address
- Error Error relocating /usr/lib/python2.7/OmegaExpansion/onionI2C.so: i2c_writeBufferRaw: symbol not found" HOT 4
- Compilation error: recompile with -fPIC HOT 1
- I2C functions never return an error
- Problem with oled-exp cursor command HOT 2
- I2C driver causing segmentation fault in onion-i2c.c HOT 4
- setCursor() function in Python module returns "I2C transaction failed." HOT 3
- Timming issues
- Document maximum I2C transfer size of 64 bytes HOT 5
- Instructions on how to build/install for Python 3 HOT 2
- Image skewed by OLEC Expansion Control of Control Panel after b236 HOT 14
- OLED_EXP_CHAR_COLUMN not OLED_EXP_CHAR_COLUMNS HOT 1
- oled-exp segmentation fault when using the draw command
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from i2c-exp-driver.