no need to loop, only one block
This commit is contained in:
parent
5a87f1f3db
commit
dd96571f88
1 changed files with 10 additions and 13 deletions
|
@ -491,9 +491,8 @@ write_card(int write_block_zero)
|
||||||
|
|
||||||
//Write Block 0 if requested to do so
|
//Write Block 0 if requested to do so
|
||||||
if (write_block_zero) {
|
if (write_block_zero) {
|
||||||
for (uiBlock = 0; uiBlock < 1; uiBlock++) {
|
uiBlock = 0;
|
||||||
|
is_first_block(0);
|
||||||
if (is_first_block(uiBlock)) {
|
|
||||||
if (bFailure) {
|
if (bFailure) {
|
||||||
// When a failure occured we need to redo the anti-collision
|
// When a failure occured we need to redo the anti-collision
|
||||||
if (nfc_initiator_select_passive_target(pnd, nmMifare, NULL, 0, &nt) <= 0) {
|
if (nfc_initiator_select_passive_target(pnd, nmMifare, NULL, 0, &nt) <= 0) {
|
||||||
|
@ -509,12 +508,11 @@ write_card(int write_block_zero)
|
||||||
// If we're writing to a One Time Write, we need to authenticate
|
// If we're writing to a One Time Write, we need to authenticate
|
||||||
// If we're writing something else, we'll need to authenticate
|
// If we're writing something else, we'll need to authenticate
|
||||||
if ((write_block_zero && magic3) || !write_block_zero) {
|
if ((write_block_zero && magic3) || !write_block_zero) {
|
||||||
if (!authenticate(uiBlock) && !bTolerateFailures) {
|
if (!authenticate(0) && !bTolerateFailures) {
|
||||||
printf("!\nError: authentication failed for block %02x\n", uiBlock);
|
printf("!\nError: authentication failed for block 00\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure a earlier write did not fail
|
// Make sure a earlier write did not fail
|
||||||
if (!bFailure) {
|
if (!bFailure) {
|
||||||
|
@ -531,7 +529,7 @@ write_card(int write_block_zero)
|
||||||
}
|
}
|
||||||
if (!nfc_initiator_mifare_cmd(pnd, MC_WRITE, uiBlock, &mp)) {
|
if (!nfc_initiator_mifare_cmd(pnd, MC_WRITE, uiBlock, &mp)) {
|
||||||
bFailure = true;
|
bFailure = true;
|
||||||
printf("Failure to write to data block %i\n", uiBlock);
|
printf("Failure to write to data block 0\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -544,7 +542,6 @@ write_card(int write_block_zero)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
printf("|\n");
|
printf("|\n");
|
||||||
printf("Done, %d of %d blocks written.\n", uiWriteBlocks, uiBlocks + 1);
|
printf("Done, %d of %d blocks written.\n", uiWriteBlocks, uiBlocks + 1);
|
||||||
|
|
Loading…
Reference in a new issue