fixed dead assignment

This commit is contained in:
Frank Morgner 2017-10-31 10:12:12 +01:00
parent 9c025280a6
commit 1d03000222
16 changed files with 34 additions and 24 deletions

View File

@ -971,7 +971,6 @@ static int asepcos_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *pdata,
}
if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00) {
/* unable to verify the old PIN */
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
break;
}
/* 2, step: use CHANGE KEY to update the PIN */
@ -981,7 +980,6 @@ static int asepcos_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *pdata,
r = sc_transmit_apdu(card, &apdu);
if (r != SC_SUCCESS)
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "APDU transmit failed");
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
break;
case SC_PIN_CMD_UNBLOCK:
if (pdata->pin_type != SC_AC_CHV)
@ -1008,7 +1006,6 @@ static int asepcos_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *pdata,
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "APDU transmit failed");
break;
}
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "error: unknow cmd type");

View File

@ -1259,7 +1259,6 @@ static int gids_create_keyfile(sc_card_t *card, sc_pkcs15_object_t *object) {
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL);
}
// else can be empty if not record
keymaprecordnum = 0;
keymapbuffersize = 0;
} else {
keymaprecordnum = (keymapbuffersize - 1) / sizeof(struct gids_keymap_record);

View File

@ -82,11 +82,10 @@ jpki_finish(sc_card_t * card)
struct jpki_private_data *drvdata = JPKI_DRVDATA(card);
LOG_FUNC_CALLED(card->ctx);
if (drvdata->mf) {
free(drvdata->mf);
drvdata->mf = NULL;
}
if (drvdata) {
if (drvdata->mf) {
free(drvdata->mf);
}
free(drvdata);
card->drv_data = NULL;
}

View File

@ -925,6 +925,7 @@ myeid_compute_raw_2048_signature(struct sc_card *card, const u8 * data, size_t d
apdu.data = sbuf;
r = sc_transmit_apdu(card, &apdu);
LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
/* prepare 2nd part of data */
sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x2A, 0x80, 0x86);
@ -1270,7 +1271,6 @@ static int myeid_loadkey(sc_card_t *card, int mode, u8* value, int value_len)
if(mode == LOAD_KEY_MODULUS && value_len >= 256)
{
r=0;
if((value_len % 2) > 0 && value[0] == 0x00)
{
value_len--;

View File

@ -3122,12 +3122,12 @@ static int piv_init(sc_card_t *card)
* We want to process them now as this has information on what
* keys and certs the card has and how the pin might be used.
*/
r = piv_process_history(card);
piv_process_history(card);
r = piv_process_discovery(card);
if (r > 0)
r = 0;
LOG_FUNC_RETURN(card->ctx, r);
}
@ -3294,7 +3294,7 @@ piv_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data, int *tries_left)
/* if access to applet is know to be reset by other driver we select_aid and try again */
if ( priv->card_issues & CI_OTHER_AID_LOSE_STATE && priv->pin_cmd_verify_sw1 == 0x6DU) {
sc_log(card->ctx, "AID may be lost doing piv_find_aid and retry pin_cmd");
r = piv_find_aid(card, priv->aid_file); /* return not tested */
piv_find_aid(card, priv->aid_file); /* return not tested */
priv->pin_cmd_verify = 1; /* tell piv_check_sw its a verify to save sw1, sw2 */
r = iso_drv->ops->pin_cmd(card, data, tries_left);

View File

@ -788,10 +788,11 @@ static int msc_compute_crypt_final_object(
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed");
if(apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
r = msc_read_object(card, inputId, 2, outputData, dataLength);
*outputDataLength = dataLength;
if (r >= 0)
*outputDataLength = r;
msc_delete_object(card, outputId, 0);
msc_delete_object(card, inputId, 0);
return 0;
return r;
}
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
if (r) {

View File

@ -55,6 +55,8 @@ static int sc_pkcs15emu_entersafe_init( sc_pkcs15_card_t *p15card)
/* get serial number */
r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serial);
if (r != SC_SUCCESS)
return SC_ERROR_INTERNAL;
r = sc_bin_to_hex(serial.value, serial.len, buf, sizeof(buf), 0);
if (r != SC_SUCCESS)
return SC_ERROR_INTERNAL;

View File

@ -225,9 +225,11 @@ static int sc_pkcs15emu_gemsafeGPK_init(sc_pkcs15_card_t *p15card)
p15card->tokeninfo->manufacturer_id = strdup(MANU_ID);
/* get serial number */
r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serial);
if (r != SC_SUCCESS)
return SC_ERROR_INTERNAL;
r = sc_bin_to_hex(serial.value, serial.len, buf, sizeof(buf), 0);
if (r != SC_SUCCESS)
return SC_ERROR_INTERNAL;
if (r != SC_SUCCESS)
return SC_ERROR_INTERNAL;
p15card->tokeninfo->serial_number = strdup(buf);
/* test if we have a gemsafe app df */

View File

@ -60,7 +60,6 @@ _iasecc_md_update_keyinfo(struct sc_pkcs15_card *p15card, struct sc_pkcs15_objec
LOG_TEST_RET(ctx, rv, "Failed to read container DATA object data");
offs = 0;
rv = SC_ERROR_INVALID_DATA;
if (*(ddata->data + offs++) != 0x01) {
sc_pkcs15_free_data_object(ddata);
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);

View File

@ -774,7 +774,7 @@ static int infocamere_1600_init(sc_pkcs15_card_t * p15card)
/* return to MF */
sc_format_path("3F00", &path);
r = sc_select_file(card, &path, NULL);
sc_select_file(card, &path, NULL);
return SC_SUCCESS;
}

View File

@ -369,12 +369,15 @@ sc_pkcs15emu_openpgp_init(sc_pkcs15_card_t *p15card)
}
/* PKCS#15 DATA object from OpenPGP private DOs */
r = sc_pkcs15emu_openpgp_add_data(p15card);
sc_pkcs15emu_openpgp_add_data(p15card);
return 0;
failed:
if (r < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
"Failed to initialize OpenPGP emulation: %s\n",
sc_strerror(r));
}
failed: sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Failed to initialize OpenPGP emulation: %s\n",
sc_strerror(r));
return r;
}

View File

@ -164,6 +164,8 @@ static int sc_pkcs15emu_starcert_init(sc_pkcs15_card_t *p15card)
/* get serial number */
r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serial);
if (r != SC_SUCCESS)
return SC_ERROR_INTERNAL;
r = sc_bin_to_hex(serial.value, serial.len, buf, sizeof(buf), 0);
if (r != SC_SUCCESS)
return SC_ERROR_INTERNAL;

View File

@ -54,6 +54,8 @@ static int sc_pkcs15emu_westcos_init(sc_pkcs15_card_t * p15card)
/* get serial number */
r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serial);
if (r)
goto out;
r = sc_bin_to_hex(serial.value, serial.len, buf, sizeof(buf), 0);
if (r)
goto out;

View File

@ -158,6 +158,8 @@ static void do_esteid(sc_card_t *card)
/* print the counters */
for (i = 1; i <= 4; i++) {
r = sc_read_record(card, i, buff, 128, SC_RECORD_BY_REC_NR);
if (r < 0)
goto out;
key_used[i - 1] = 0xffffff - ((unsigned char) buff[0xc] * 65536
+ (unsigned char) buff[0xd] * 256
+ (unsigned char) buff[0xe]);

View File

@ -449,6 +449,10 @@ int do_genkey(sc_card_t *card, u8 key_id, unsigned int key_len)
}
sc_format_path("006E007300C5", &path);
r = sc_select_file(card, &path, &file);
if (r < 0) {
printf("Failed to retrieve fingerprints. Error %s.\n", sc_strerror(r));
return 1;
}
r = sc_read_binary(card, 0, fingerprints, 60, 0);
if (r < 0) {
printf("Failed to retrieve fingerprints. Error %s.\n", sc_strerror(r));

View File

@ -1072,7 +1072,6 @@ cmdline_parser_internal (
int override;
int initialize;
int check_required;
int check_ambiguity;
char *optarg;
@ -1084,7 +1083,6 @@ cmdline_parser_internal (
override = params->override;
initialize = params->initialize;
check_required = params->check_required;
check_ambiguity = params->check_ambiguity;
if (initialize)