ISSUE-4108: nfc: fix value-block BusFault and add unit test + test file generator#4352
Open
herbenderbler wants to merge 1 commit intoflipperdevices:devfrom
Open
ISSUE-4108: nfc: fix value-block BusFault and add unit test + test file generator#4352herbenderbler wants to merge 1 commit intoflipperdevices:devfrom
herbenderbler wants to merge 1 commit intoflipperdevices:devfrom
Conversation
| I tried building a firmware with this change included and it unfortunately didn't fix the crash. It's not impossible the crash I'm seeing is a different bug. |
Author
Thanks for that feedback. Let me take another pass at it. How can I replicate the crash/error you received? Would you mind dropping more details in this thread? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a crash during MIFARE Classic write flows when value blocks are encountered (reported as NFC BusFault in issue #4108).
Problem:
During write-condition evaluation, value blocks were flagged as
is_value_block = true, but the write/read key type fields in the write context were not initialized on that path. Later logic consumed those fields, which could result in invalid enum usage and a BusFault during NFC write operations.Affected code path:
Solution:
In the value-block branch of
mf_classic_handler_check_write_conditions():KeyAorKeyB) based on read access.key_type_readandkey_type_writebefore any downstream use.need_halt_before_write = falsefor value-block flow.ReadBlockand exit early from this handler path to avoid falling through into non-value-block key derivation logic.Also added:
Verification
Performed
./fbt firmware_all) to verify integration/compilation.gcc -c -I. -Ilib -Ifuri -Itargets/f7/furi_hal -Itargets/f7/furi -Iapplications/debug/unit_tests/tests applications/debug/unit_tests/tests/nfc/mf_classic_write_value_block_test.c -o /tmp/test_compile.oRecommended/Prepared
unit_testsapp set.Checklist (For Reviewer)