Skip to content

Commit 5c9b8ac

Browse files
committed
Fix NFC read stuck on Mifare Ultralight when signature read fails (fix #4106)
Treat Read Signature as optional: if the card supports it but the command fails (e.g. FWT timeout), continue to Auth/ReadPages instead of aborting the read. Zero the signature buffer on failure. Unify Auth/AuthMfulC choice in read_signature handler. Made-with: Cursor
1 parent c9ab2b6 commit 5c9b8ac

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

lib/nfc/protocols/mf_ultralight/mf_ultralight_poller.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,22 +305,34 @@ static NfcCommand mf_ultralight_poller_handler_get_feature_set(MfUltralightPolle
305305
}
306306

307307
static NfcCommand mf_ultralight_poller_handler_read_signature(MfUltralightPoller* instance) {
308-
MfUltralightPollerState next_state = MfUltralightPollerStateAuth;
308+
bool signature_read_ok = false;
309+
309310
if(mf_ultralight_support_feature(
310311
instance->feature_set, MfUltralightFeatureSupportReadSignature)) {
311312
FURI_LOG_D(TAG, "Reading signature");
312313
instance->error =
313314
mf_ultralight_poller_read_signature(instance, &instance->data->signature);
314-
if(instance->error != MfUltralightErrorNone) {
315-
FURI_LOG_D(TAG, "Read signature failed");
316-
next_state = MfUltralightPollerStateReadFailed;
315+
if(instance->error == MfUltralightErrorNone) {
316+
signature_read_ok = true;
317+
} else {
318+
FURI_LOG_D(TAG, "Read signature failed, continuing without signature");
319+
memset(
320+
instance->data->signature.data,
321+
0,
322+
sizeof(instance->data->signature.data));
317323
}
318324
} else {
319325
FURI_LOG_D(TAG, "Skip reading signature");
320-
if(mf_ultralight_support_feature(
321-
instance->feature_set, MfUltralightFeatureSupportAuthenticate)) {
322-
next_state = MfUltralightPollerStateAuthMfulC;
323-
}
326+
}
327+
328+
MfUltralightPollerState next_state;
329+
if(signature_read_ok) {
330+
next_state = MfUltralightPollerStateAuth;
331+
} else if(mf_ultralight_support_feature(
332+
instance->feature_set, MfUltralightFeatureSupportAuthenticate)) {
333+
next_state = MfUltralightPollerStateAuthMfulC;
334+
} else {
335+
next_state = MfUltralightPollerStateAuth;
324336
}
325337
instance->state = next_state;
326338

0 commit comments

Comments
 (0)