Skip to content
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

NFC: fix memory corruption in nfc_worker_read_mifare_desfire #1156

Merged
merged 6 commits into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions applications/nfc/nfc_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ static bool nfc_device_save_mifare_df_app(FlipperFormat* file, MifareDesfireAppl
file, app->key_settings, string_get_cstr(prefix)))
break;
}
if(!app->file_head) break;
uint32_t n_files = 0;
for(MifareDesfireFile* f = app->file_head; f; f = f->next) {
n_files++;
Expand Down Expand Up @@ -477,6 +478,7 @@ static bool nfc_device_save_mifare_df_data(FlipperFormat* file, NfcDevice* dev)
n_apps++;
}
if(!flipper_format_write_uint32(file, "Application Count", &n_apps, 1)) break;
if(n_apps == 0) break;
tmp = malloc(n_apps * 3);
int i = 0;
for(MifareDesfireApplication* app = data->app_head; app; app = app->next) {
Expand Down
2 changes: 2 additions & 0 deletions applications/nfc/nfc_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ void nfc_worker_read_mifare_desfire(NfcWorker* nfc_worker) {
FURI_LOG_W(TAG, "Bad DESFire GET_KEY_SETTINGS response");
free(data->master_key_settings);
data->master_key_settings = NULL;
continue;
}

MifareDesfireKeyVersion** key_version_head =
Expand Down Expand Up @@ -593,6 +594,7 @@ void nfc_worker_read_mifare_desfire(NfcWorker* nfc_worker) {
FURI_LOG_W(TAG, "Bad DESFire GET_KEY_SETTINGS response");
free(app->key_settings);
app->key_settings = NULL;
continue;
}

MifareDesfireKeyVersion** key_version_head = &app->key_settings->key_version_head;
Expand Down