Skip to content

Commit 7154337

Browse files
committed
Wire: Fix buffer overflow in requestFrom.
Fixes #813 Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
1 parent 59ec204 commit 7154337

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

libraries/Wire/Wire.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ uint8_t arduino::MbedI2C::endTransmission(void) {
9393

9494
size_t arduino::MbedI2C::requestFrom(uint8_t address, size_t len, bool stopBit) {
9595
char buf[256];
96+
len = min(len, sizeof(buf));
9697
int ret = master->read(address << 1, buf, len, !stopBit);
9798
if (ret != 0) {
9899
return 0;

0 commit comments

Comments
 (0)