Skip to content

Commit 22164c7

Browse files
committedNov 4, 2019
Fix buffer index overflow
1 parent 3685015 commit 22164c7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎PN5180.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ status register contain information on the exception.
445445
bool PN5180::transceiveCommand(uint8_t *sendBuffer, size_t sendBufferLen, uint8_t *recvBuffer, size_t recvBufferLen) {
446446
#ifdef DEBUG
447447
PN5180DEBUG(F("Sending SPI frame: '"));
448-
for (uint8_t i=0; i<sendBufferLen; i++) {
448+
for (size_t i=0; i<sendBufferLen; i++) {
449449
if (i>0) PN5180DEBUG(" ");
450450
PN5180DEBUG(formatHex(sendBuffer[i]));
451451
}
@@ -457,7 +457,7 @@ bool PN5180::transceiveCommand(uint8_t *sendBuffer, size_t sendBufferLen, uint8_
457457
// 1.
458458
digitalWrite(PN5180_NSS, LOW); delay(2);
459459
// 2.
460-
for (uint8_t i=0; i<sendBufferLen; i++) {
460+
for (size_t i=0; i<sendBufferLen; i++) {
461461
SPI.transfer(sendBuffer[i]);
462462
}
463463
// 3.
@@ -475,7 +475,7 @@ bool PN5180::transceiveCommand(uint8_t *sendBuffer, size_t sendBufferLen, uint8_
475475
// 1.
476476
digitalWrite(PN5180_NSS, LOW); delay(2);
477477
// 2.
478-
for (uint8_t i=0; i<recvBufferLen; i++) {
478+
for (size_t i=0; i<recvBufferLen; i++) {
479479
recvBuffer[i] = SPI.transfer(0xff);
480480
}
481481
// 3.
@@ -487,7 +487,7 @@ bool PN5180::transceiveCommand(uint8_t *sendBuffer, size_t sendBufferLen, uint8_
487487

488488
#ifdef DEBUG
489489
PN5180DEBUG(F("Received: "));
490-
for (uint8_t i=0; i<recvBufferLen; i++) {
490+
for (size_t i=0; i<recvBufferLen; i++) {
491491
if (i > 0) PN5180DEBUG(" ");
492492
PN5180DEBUG(formatHex(recvBuffer[i]));
493493
}

0 commit comments

Comments
 (0)
Please sign in to comment.