-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 #3347 by implementing a read loop until all file bytes are read. #3349
Conversation
This issue likely also exists in the "read file value" and "read file records" code paths. I've only fixed the "read normal file" path. |
Fix an off-by-one bug which drops DESFire responses which are actually perfectly fine. The bug occurs due to the fact that the response handling code forgets to discount the "MF_DESFIRE_FLAG_HAS_NEXT" byte at the front of all continued reponses, and thus, determines that the reponse is too big (by one byte).
Update the file read loop to size its read requests perfectly for the receive buffer, rather than banging its head repeatedly against the wall in the receive handler by dropping incoming responses.
As noted in #3347, I've pushed in some more fixes to this PR. One fixes an off-by-one counting bug which was causing received responses to be thrown away when they actually were perfectly fine. The other is a change to the file read polling loop such that it requests no more bytes than can actually fit into the receive buffer. |
@@ -301,24 +303,35 @@ MfDesfireError mf_desfire_poller_read_file_data( | |||
size_t size, | |||
MfDesfireFileData* data) { | |||
furi_assert(instance); | |||
size_t cur_offset, read_size, num_read; | |||
MfDesfireError error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compiler thinks that we might not get into for loop, where we update error variable. Please, initialize this variable here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. I'll look at it this week.
Un-draft when ready |
Fixed arrive in dev |
What's new
This fixes #3347 by implementing a read loop which reads the file bit by bit until completed.
Verification
Tested with a Mifare DESFire card which exhibited the initial issue.
Checklist (For Reviewer)