Skip to content

Commit 3750131

Browse files
committed
Merge pull request arduino#2781 from arve0/yun_bridge_bug_read_forever
Bridge: discard message if length is bigger than buffer size
2 parents ec1db8c + ff48ee4 commit 3750131

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

libraries/Bridge/src/Bridge.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,13 @@ uint16_t BridgeClass::transfer(const uint8_t *buff1, uint16_t len1,
191191

192192
// Recv data
193193
for (uint16_t i = 0; i < l; i++) {
194+
// Cut received data if rxbuffer is too small
195+
if (i >= rxlen)
196+
break;
194197
int c = timedRead(5);
195198
if (c < 0)
196199
continue;
197-
// Cut received data if rxbuffer is too small
198-
if (i < rxlen)
199-
rxbuff[i] = c;
200+
rxbuff[i] = c;
200201
crcUpdate(c);
201202
}
202203

0 commit comments

Comments
 (0)