Skip to content

Commit da24fee

Browse files
authored
Fix data buffer overflow wrong length bytes
Sometimes receiving byte 6 or 7 is wrong and packet->length will be very high. There was no check that any more bytes could fit into the packet->data buffer. This could resulted in crashes or strange behavior.
1 parent 2124319 commit da24fee

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Adafruit_Fingerprint.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,10 @@ Adafruit_Fingerprint::getStructuredPacket(Adafruit_Fingerprint_Packet *packet,
559559
break;
560560
}
561561
idx++;
562+
if ((idx + 9) >= sizeof(packet->data))
563+
{
564+
return FINGERPRINT_BADPACKET;
565+
}
562566
}
563567
// Shouldn't get here so...
564568
return FINGERPRINT_BADPACKET;

0 commit comments

Comments
 (0)