Explorar o código

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 <tonyfreeman@users.noreply.github.com>
tonyfreeman %!s(int64=4) %!d(string=hai) anos
pai
achega
a7edebce69

+ 1 - 1
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();
 };

+ 1 - 1
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++) {