Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for partially read ultralight tag #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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