Topic: Bug in nfc-mfclassic.c
Hi there,
the current version of nfc-mfclassic.c (revision 178) contains a small bug:
get_trailer_block assumes that we are at the first block, when calculating the trailer block number,
but when authenticating in read_card(), that's not always true.
(BTW: Why does the block reading start at the last block, not the first?)
I fixed it like this:
===================================================================
--- examples/nfc-mfclassic.c (revision 178)
+++ examples/nfc-mfclassic.c (working copy)
@@ -69,8 +69,17 @@
uint32_t get_trailer_block(uint32_t uiFirstBlock)
{
+ uint32_t trailer_block = 0;
+
+ if (uiFirstBlock < 128) {
+ trailer_block = uiFirstBlock + (3 - (uiFirstBlock % 4));
+ } else {
+ trailer_block = uiFirstBlock + (15 - (uiFirstBlock % 16));
+ }
+ return trailer_block;
+
// Test if we are in the small or big sectors
- if (uiFirstBlock<128) return uiFirstBlock+3; else return uiFirstBlock+15;
+ // if (uiFirstBlock<128) return uiFirstBlock+3; else return uiFirstBlock+15;
}