Fix scan-build issues

This commit is contained in:
Charles-Edouard de la Vergne 2023-10-18 18:25:54 +02:00
parent d72445db42
commit 1b7e959b1b
No known key found for this signature in database
GPG Key ID: F12296941B7BB9C6
4 changed files with 9 additions and 10 deletions

View File

@ -409,11 +409,13 @@ int gpg_apdu_put_data(unsigned int ref) {
pkey_size = sizeof(cx_rsa_4096_private_key_t); pkey_size = sizeof(cx_rsa_4096_private_key_t);
pq = G_gpg_vstate.work.rsa.public4096.n; pq = G_gpg_vstate.work.rsa.public4096.n;
break; break;
default:
THROW(SW_WRONG_DATA);
return 0;
} }
ksz = ksz >> 1; ksz = ksz >> 1;
// fetch e // fetch e
e = 0;
switch (len_e) { switch (len_e) {
case 4: case 4:
e = gpg_io_fetch_u32(); e = gpg_io_fetch_u32();
@ -465,7 +467,6 @@ int gpg_apdu_put_data(unsigned int ref) {
(keygpg->attributes.value[0] == 22)) { (keygpg->attributes.value[0] == 22)) {
unsigned int curve; unsigned int curve;
ksz = 0;
curve = gpg_oid2curve(&keygpg->attributes.value[1], keygpg->attributes.length - 1); curve = gpg_oid2curve(&keygpg->attributes.value[1], keygpg->attributes.length - 1);
if (curve == 0) { if (curve == 0) {
THROW(SW_WRONG_DATA); THROW(SW_WRONG_DATA);

View File

@ -261,7 +261,7 @@ int gpg_io_do(unsigned int io_flags) {
xx = G_gpg_vstate.io_length - 2; xx = G_gpg_vstate.io_length - 2;
} }
G_io_apdu_buffer[tx + 1] = xx; 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 // check get response
if ((G_io_apdu_buffer[0] != 0x00) || (G_io_apdu_buffer[1] != 0xc0) || 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)) { (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); G_gpg_vstate.io_length);
if (io_flags & IO_RETURN_AFTER_TX) { 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; 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 --- //--- full in chaining ---
@ -288,7 +287,6 @@ int gpg_io_do(unsigned int io_flags) {
} }
if (rx == 4) { if (rx == 4) {
G_io_apdu_buffer[4] = 0; G_io_apdu_buffer[4] = 0;
rx = 4;
} }
G_gpg_vstate.io_offset = 0; G_gpg_vstate.io_offset = 0;
G_gpg_vstate.io_length = 0; G_gpg_vstate.io_length = 0;
@ -343,7 +341,6 @@ int gpg_io_do(unsigned int io_flags) {
} }
if (rx == 4) { if (rx == 4) {
G_io_apdu_buffer[4] = 0; G_io_apdu_buffer[4] = 0;
rx = 4;
} }
G_gpg_vstate.io_cla = G_io_apdu_buffer[0]; G_gpg_vstate.io_cla = G_io_apdu_buffer[0];
G_gpg_vstate.io_lc = G_io_apdu_buffer[4]; G_gpg_vstate.io_lc = G_io_apdu_buffer[4];

View File

@ -85,6 +85,9 @@ static int gpg_sign(gpg_key_t *sigkey) {
case 4096 / 8: case 4096 / 8:
key = (cx_rsa_private_key_t *) &sigkey->priv_key.rsa4096; key = (cx_rsa_private_key_t *) &sigkey->priv_key.rsa4096;
break; break;
default:
THROW(SW_DATA_INVALID);
return 0;
} }
if (key->size != ksz) { if (key->size != ksz) {
THROW(SW_CONDITIONS_NOT_SATISFIED); THROW(SW_CONDITIONS_NOT_SATISFIED);

View File

@ -171,7 +171,6 @@ unsigned int ui_uifconfirm_action(unsigned int value) {
gpg_io_insert_u16(sw); gpg_io_insert_u16(sw);
gpg_io_do(IO_RETURN_AFTER_TX); gpg_io_do(IO_RETURN_AFTER_TX);
ui_menu_main_display(0); ui_menu_main_display(0);
sw = 0x6985;
} }
return 0; return 0;
} }
@ -228,7 +227,6 @@ void ui_menu_pinconfirm_display(unsigned int value) {
unsigned int ui_pinconfirm_action(unsigned int value) { unsigned int ui_pinconfirm_action(unsigned int value) {
unsigned int sw; unsigned int sw;
sw = 0x6985;
if (value == 1) { if (value == 1) {
gpg_pin_set_verified(G_gpg_vstate.io_p2, 1); gpg_pin_set_verified(G_gpg_vstate.io_p2, 1);
sw = 0x9000; sw = 0x9000;