Skip to content

Commit bda03d1

Browse files
committed
i2c: fix ioctl buffer size
The I2C_FUNCS ioctl expects an unsigned long output argument[1]. However, we currently create a buffer using the 'I' (unsigned int) specifier. On platforms where sizeof(unsigned int) < sizeof(unsigned long), this results in a buffer that is too small. This has always been a problem but with Python 3.14, the ioctl interface has some logic to detect this kind of buffer overflow[2], causing a SystemError to be raised when trying to create a new I2C object. Fix the type specifier to align with what the ioctl expects. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/i2c/dev-interface.rst?h=v7.0-rc2#n124 [2] python/cpython@c2eaeee
1 parent c3b9d0f commit bda03d1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

periphery/i2c.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def _open(self, devpath):
7676
self._devpath = devpath
7777

7878
# Query supported functions
79-
buf = array.array('I', [0])
79+
buf = array.array('L', [0])
8080
try:
8181
fcntl.ioctl(self._fd, I2C._I2C_IOC_FUNCS, buf, True)
8282
except (OSError, IOError) as e:

0 commit comments

Comments
 (0)