Buffer boundary check - test 1

This commit is contained in:
GHOSCHT 2021-08-26 14:39:52 +02:00
parent 383c903aa1
commit 1c0c744983

View file

@ -76,8 +76,12 @@ void receiveEvent(int byteCount)
char buffer[byteCount]; char buffer[byteCount];
for (int i = 0; i < byteCount; i++) for (int i = 0; i < byteCount; i++)
{ {
if (i == byteCount)
break;
buffer[i] = Wire.read(); buffer[i] = Wire.read();
} }
memset(receivedI2cData, ' ', 3); memset(receivedI2cData, ' ', 3);
strcpy(receivedI2cData, buffer); strcpy(receivedI2cData, buffer);
} }