Skip to content

Commit 8d4d1dc

Browse files
fix potential arrary overflow problem of _recvBuffer (#214)
* fix potential arrary overflow problem of _recvBuffer * Update src/utility/HCI.cpp make the code eaiser to read Co-authored-by: Alexander Entinger <[email protected]> * optimize code of potential overflow _recvBuffer * add the debug msg when the _recvBuffer overflow Co-authored-by: Alexander Entinger <[email protected]>
1 parent 95b2449 commit 8d4d1dc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: src/utility/HCI.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ void HCIClass::poll(unsigned long timeout)
112112

113113
while (HCITransport.available()) {
114114
byte b = HCITransport.read();
115+
116+
if (_recvIndex >= sizeof(_recvBuffer)) {
117+
_recvIndex = 0;
118+
if (_debug) {
119+
_debug->println("_recvBuffer overflow");
120+
}
121+
}
115122

116123
_recvBuffer[_recvIndex++] = b;
117124

0 commit comments

Comments
 (0)