Skip to content

Conversation

@benhowes
Copy link

@benhowes benhowes commented Feb 2, 2021

In my use case, I found it relatively common to be able to retrieve partial NDEF messages, for example a tag with a URI ndef record of https://example.com, would often be returned as http!I��⸮�⸮��⸮⸮���⸮���⸮, due to reading uninitialized memory.

It seems to happen due to:

  1. The MifareUltralight::read calls the NdefMessage constructor regardless of if the messageLength is 0
  2. Line 20 of the NdefMessage::NdefMessage constructor contains while (index <= numBytes) - which does allow a partial NDEF message to be processed, even if numBytes is 0.

My fix is to not call the NdefMessage constructor if there was an error reading the message.

It seems to make corrupted reads a thing of the past for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant