From 1b7e959b1b8a4a1353801c036c0be94fcdc7964b Mon Sep 17 00:00:00 2001 From: Charles-Edouard de la Vergne Date: Wed, 18 Oct 2023 18:25:54 +0200 Subject: [PATCH] Fix scan-build issues --- src/gpg_data.c | 5 +++-- src/gpg_io.c | 9 +++------ src/gpg_pso.c | 3 +++ src/gpg_ux_nanox.c | 2 -- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/gpg_data.c b/src/gpg_data.c index 14bbd5b..65af816 100644 --- a/src/gpg_data.c +++ b/src/gpg_data.c @@ -409,11 +409,13 @@ int gpg_apdu_put_data(unsigned int ref) { pkey_size = sizeof(cx_rsa_4096_private_key_t); pq = G_gpg_vstate.work.rsa.public4096.n; break; + default: + THROW(SW_WRONG_DATA); + return 0; } ksz = ksz >> 1; // fetch e - e = 0; switch (len_e) { case 4: e = gpg_io_fetch_u32(); @@ -465,7 +467,6 @@ int gpg_apdu_put_data(unsigned int ref) { (keygpg->attributes.value[0] == 22)) { unsigned int curve; - ksz = 0; curve = gpg_oid2curve(&keygpg->attributes.value[1], keygpg->attributes.length - 1); if (curve == 0) { THROW(SW_WRONG_DATA); diff --git a/src/gpg_io.c b/src/gpg_io.c index edcf085..1551299 100644 --- a/src/gpg_io.c +++ b/src/gpg_io.c @@ -261,7 +261,7 @@ int gpg_io_do(unsigned int io_flags) { xx = G_gpg_vstate.io_length - 2; } G_io_apdu_buffer[tx + 1] = xx; - rx = gpg_io_exchange(CHANNEL_APDU, tx + 2); + gpg_io_exchange(CHANNEL_APDU, tx + 2); // check get response if ((G_io_apdu_buffer[0] != 0x00) || (G_io_apdu_buffer[1] != 0xc0) || (G_io_apdu_buffer[2] != 0x00) || (G_io_apdu_buffer[3] != 0x00)) { @@ -274,11 +274,10 @@ int gpg_io_do(unsigned int io_flags) { G_gpg_vstate.io_length); if (io_flags & IO_RETURN_AFTER_TX) { - rx = gpg_io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, G_gpg_vstate.io_length); + gpg_io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, G_gpg_vstate.io_length); return 0; - } else { - rx = gpg_io_exchange(CHANNEL_APDU, G_gpg_vstate.io_length); } + rx = io_exchange(CHANNEL_APDU, G_gpg_vstate.io_length); } //--- full in chaining --- @@ -288,7 +287,6 @@ int gpg_io_do(unsigned int io_flags) { } if (rx == 4) { G_io_apdu_buffer[4] = 0; - rx = 4; } G_gpg_vstate.io_offset = 0; G_gpg_vstate.io_length = 0; @@ -343,7 +341,6 @@ int gpg_io_do(unsigned int io_flags) { } if (rx == 4) { G_io_apdu_buffer[4] = 0; - rx = 4; } G_gpg_vstate.io_cla = G_io_apdu_buffer[0]; G_gpg_vstate.io_lc = G_io_apdu_buffer[4]; diff --git a/src/gpg_pso.c b/src/gpg_pso.c index 64fa73b..7f90a56 100644 --- a/src/gpg_pso.c +++ b/src/gpg_pso.c @@ -85,6 +85,9 @@ static int gpg_sign(gpg_key_t *sigkey) { case 4096 / 8: key = (cx_rsa_private_key_t *) &sigkey->priv_key.rsa4096; break; + default: + THROW(SW_DATA_INVALID); + return 0; } if (key->size != ksz) { THROW(SW_CONDITIONS_NOT_SATISFIED); diff --git a/src/gpg_ux_nanox.c b/src/gpg_ux_nanox.c index 0a914b8..227d842 100644 --- a/src/gpg_ux_nanox.c +++ b/src/gpg_ux_nanox.c @@ -171,7 +171,6 @@ unsigned int ui_uifconfirm_action(unsigned int value) { gpg_io_insert_u16(sw); gpg_io_do(IO_RETURN_AFTER_TX); ui_menu_main_display(0); - sw = 0x6985; } return 0; } @@ -228,7 +227,6 @@ void ui_menu_pinconfirm_display(unsigned int value) { unsigned int ui_pinconfirm_action(unsigned int value) { unsigned int sw; - sw = 0x6985; if (value == 1) { gpg_pin_set_verified(G_gpg_vstate.io_p2, 1); sw = 0x9000;