From a7edebce69039ba65b31a18b57062c29bc39c867 Mon Sep 17 00:00:00 2001 From: tonyfreeman <24860049+tonyfreeman@users.noreply.github.com> Date: Mon, 4 Oct 2021 02:30:47 +0300 Subject: [PATCH] RFID: Fix integer overflow, fix printf usage (#742) * Fix comparison of constant 300 with expression of type 'uint8_t' is always false rfid-worker.cpp:111 if(validate_counts > (5 * 60)) * Fix format string is not a string literal (potentially insecure) Co-authored-by: Tony Freeman --- applications/lfrfid/helpers/rfid-worker.h | 2 +- applications/lfrfid/lfrfid-cli.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/lfrfid/helpers/rfid-worker.h b/applications/lfrfid/helpers/rfid-worker.h index c2533a23..3efca849 100644 --- a/applications/lfrfid/helpers/rfid-worker.h +++ b/applications/lfrfid/helpers/rfid-worker.h @@ -43,6 +43,6 @@ private: void sq_write(); void sq_write_start_validate(); void sq_write_validate(); - uint8_t validate_counts; + uint16_t validate_counts; void sq_write_stop_validate(); }; \ No newline at end of file diff --git a/applications/lfrfid/lfrfid-cli.cpp b/applications/lfrfid/lfrfid-cli.cpp index a039ccc8..2422dc5f 100644 --- a/applications/lfrfid/lfrfid-cli.cpp +++ b/applications/lfrfid/lfrfid-cli.cpp @@ -55,7 +55,7 @@ void lfrfid_cli_read(Cli* cli) { printf("Reading RFID...\r\nPress Ctrl+C to abort\r\n"); while(!cli_cmd_interrupt_received(cli)) { if(reader.read(&type, data, data_size)) { - printf(lfrfid_key_get_type_string(type)); + printf("%s", lfrfid_key_get_type_string(type)); printf(" "); for(uint8_t i = 0; i < lfrfid_key_get_type_data_count(type); i++) {