Skip to content

Commit ea100a9

Browse files
JZimnolDhruvaG2000
authored andcommitted
Wire: avoid buffer overflow in arduino::ZephyrI2C::write(uint8_t)
Signed-off-by: Jakub Zimnol <zimnol.jakub@gmail.com>
1 parent 03f35e6 commit ea100a9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

libraries/Wire/Wire.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ size_t arduino::ZephyrI2C::requestFrom(uint8_t address, size_t len) { // TODO fo
6969
}
7070

7171
size_t arduino::ZephyrI2C::write(uint8_t data) { // TODO for ADS1115
72+
if (usedTxBuffer >= sizeof(txBuffer)) {
73+
return 0;
74+
}
7275
txBuffer[usedTxBuffer++] = data;
7376
return 1;
7477
}

0 commit comments

Comments
 (0)