[FL-2811] Fix PVS-Studio warnings (#2142)

Co-authored-by: あく <alleteam@gmail.com>
Co-authored-by: gornekich <n.gorbadey@gmail.com>
This commit is contained in:
Georgii Surkov
2022-12-26 15:13:30 +03:00
committed by GitHub
parent ad3bff0b67
commit 8582670a34
201 changed files with 719 additions and 743 deletions

View File

@@ -58,7 +58,7 @@ bool u2f_scene_main_on_event(void* context, SceneManagerEvent event) {
app->event_cur = event.event;
if(event.event == U2fCustomEventRegister)
u2f_view_set_state(app->u2f_view, U2fMsgRegister);
else if(event.event == U2fCustomEventAuth)
else if(event.event == U2fCustomEventAuth) //-V547
u2f_view_set_state(app->u2f_view, U2fMsgAuth);
notification_message(app->notifications, &sequence_display_backlight_on);
notification_message(app->notifications, &sequence_single_vibro);

View File

@@ -402,9 +402,9 @@ bool u2f_data_cnt_read(uint32_t* cnt_val) {
FURI_LOG_E(TAG, "Unable to load encryption key");
break;
}
memset(&cnt, 0, 32);
if(!furi_hal_crypto_decrypt(cnt_encr, (uint8_t*)&cnt, 32)) {
memset(&cnt, 0, 32);
memset(&cnt, 0, sizeof(U2fCounterData));
if(!furi_hal_crypto_decrypt(cnt_encr, (uint8_t*)&cnt, sizeof(U2fCounterData))) {
memset(&cnt, 0, sizeof(U2fCounterData));
FURI_LOG_E(TAG, "Decryption failed");
break;
}

View File

@@ -94,7 +94,7 @@ static void u2f_hid_send_response(U2fHid* u2f_hid) {
uint16_t data_ptr = 0;
memset(packet_buf, 0, HID_U2F_PACKET_LEN);
memcpy(packet_buf, &(u2f_hid->packet.cid), 4);
memcpy(packet_buf, &(u2f_hid->packet.cid), sizeof(uint32_t)); //-V1086
// Init packet
packet_buf[4] = u2f_hid->packet.cmd;
@@ -166,7 +166,7 @@ static bool u2f_hid_parse_request(U2fHid* u2f_hid) {
return false;
u2f_hid->packet.len = 17;
uint32_t random_cid = furi_hal_random_get();
memcpy(&(u2f_hid->packet.payload[8]), &random_cid, 4);
memcpy(&(u2f_hid->packet.payload[8]), &random_cid, sizeof(uint32_t)); //-V1086
u2f_hid->packet.payload[12] = 2; // Protocol version
u2f_hid->packet.payload[13] = 1; // Device version major
u2f_hid->packet.payload[14] = 0; // Device version minor
@@ -177,7 +177,7 @@ static bool u2f_hid_parse_request(U2fHid* u2f_hid) {
} else if(u2f_hid->packet.cmd == U2F_HID_WINK) { // WINK - notify user
if(u2f_hid->packet.len != 0) return false;
u2f_wink(u2f_hid->u2f_instance);
u2f_hid->packet.len = 0;
u2f_hid->packet.len = 0; //-V1048
u2f_hid_send_response(u2f_hid);
} else
return false;