Skip to content

Commit

Permalink
Make NFCID length more robust
Browse files Browse the repository at this point in the history
even if it should be 4, 7 or 10, in some cases the PN7150 reads longer values and then they would corrupt the storage for UIDs which is only accomodating maximum 10 bytes
  • Loading branch information
Strooom committed Jan 4, 2020
1 parent 34060b2 commit c611454
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/NFCReaderWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ void NFCReaderWriter::reportTagProperties(uint8_t msgBuffer[], uint8_t msgType)
}

uint8_t NfcId1Length = msgBuffer[offSet];
if (NfcId1Length > 10)
{
NfcId1Length = 10; // limit the length to 10, so in case of whatever error we don't write beyond the boundaries of the array
}
uint8_t newTagIndex = nmbrOfTags; // index to the array item where we will store the info

theTags[newTagIndex].uniqueIdLength = NfcId1Length; // copy the length of the unique ID, is 4, 7 or 10
Expand Down

0 comments on commit c611454

Please sign in to comment.