NULL parameter check moved to sc_file_free()
This fixes numerous issues where the check is *not* performed, and also simplifies the code.
This commit is contained in:
parent
2c6dadfb44
commit
645780e6d4
|
@ -565,16 +565,13 @@ authentic_set_current_files(struct sc_card *card, struct sc_path *path,
|
||||||
card->cache.current_df->path.len += cur_df_path.len;
|
card->cache.current_df->path.len += cur_df_path.len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (card->cache.current_ef) {
|
sc_file_free(card->cache.current_ef);
|
||||||
sc_file_free(card->cache.current_ef);
|
card->cache.current_ef = NULL;
|
||||||
card->cache.current_ef = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
card->cache.valid = 1;
|
card->cache.valid = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (card->cache.current_ef)
|
sc_file_free(card->cache.current_ef);
|
||||||
sc_file_free(card->cache.current_ef);
|
|
||||||
card->cache.current_ef = NULL;
|
card->cache.current_ef = NULL;
|
||||||
sc_file_dup(&card->cache.current_ef, file);
|
sc_file_dup(&card->cache.current_ef, file);
|
||||||
}
|
}
|
||||||
|
@ -625,12 +622,10 @@ authentic_select_mf(struct sc_card *card, struct sc_file **file_out)
|
||||||
LOG_TEST_RET(ctx, rv, "authentic_select_file() check SW failed");
|
LOG_TEST_RET(ctx, rv, "authentic_select_file() check SW failed");
|
||||||
|
|
||||||
if (card->cache.valid == 1) {
|
if (card->cache.valid == 1) {
|
||||||
if (card->cache.current_df)
|
sc_file_free(card->cache.current_df);
|
||||||
sc_file_free(card->cache.current_df);
|
|
||||||
card->cache.current_df = NULL;
|
card->cache.current_df = NULL;
|
||||||
|
|
||||||
if (card->cache.current_ef)
|
sc_file_free(card->cache.current_ef);
|
||||||
sc_file_free(card->cache.current_ef);
|
|
||||||
card->cache.current_ef = NULL;
|
card->cache.current_ef = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1220,7 +1215,7 @@ authentic_delete_file(struct sc_card *card, const struct sc_path *path)
|
||||||
}
|
}
|
||||||
LOG_TEST_RET(ctx, rv, "Delete file failed");
|
LOG_TEST_RET(ctx, rv, "Delete file failed");
|
||||||
|
|
||||||
if (card->cache.valid && card->cache.current_ef) {
|
if (card->cache.valid) {
|
||||||
sc_file_free(card->cache.current_ef);
|
sc_file_free(card->cache.current_ef);
|
||||||
card->cache.current_ef = NULL;
|
card->cache.current_ef = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -556,10 +556,8 @@ static int dnie_get_info(sc_card_t * card, char *data[])
|
||||||
|
|
||||||
/* phase 2: get IDESP */
|
/* phase 2: get IDESP */
|
||||||
sc_format_path("3F000006", &path);
|
sc_format_path("3F000006", &path);
|
||||||
if (file) {
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
file = NULL;
|
||||||
file = NULL;
|
|
||||||
}
|
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
free(buffer);
|
free(buffer);
|
||||||
buffer=NULL;
|
buffer=NULL;
|
||||||
|
@ -581,10 +579,8 @@ static int dnie_get_info(sc_card_t * card, char *data[])
|
||||||
get_info_ph3:
|
get_info_ph3:
|
||||||
/* phase 3: get DNIe software version */
|
/* phase 3: get DNIe software version */
|
||||||
sc_format_path("3F002F03", &path);
|
sc_format_path("3F002F03", &path);
|
||||||
if (file) {
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
file = NULL;
|
||||||
file = NULL;
|
|
||||||
}
|
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
free(buffer);
|
free(buffer);
|
||||||
buffer=NULL;
|
buffer=NULL;
|
||||||
|
@ -614,10 +610,8 @@ get_info_ph3:
|
||||||
msg = NULL;
|
msg = NULL;
|
||||||
|
|
||||||
get_info_end:
|
get_info_end:
|
||||||
if (file) {
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
file = NULL;
|
||||||
file = NULL;
|
|
||||||
}
|
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
free(buffer);
|
free(buffer);
|
||||||
buffer=NULL;
|
buffer=NULL;
|
||||||
|
@ -1206,8 +1200,7 @@ static int dnie_compose_and_send_apdu(sc_card_t *card, const u8 *path, size_t pa
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
res = card->ops->process_fci(card, file, apdu.resp + 2, apdu.resp[1]);
|
res = card->ops->process_fci(card, file, apdu.resp + 2, apdu.resp[1]);
|
||||||
if (*file_out != NULL)
|
sc_file_free(*file_out);
|
||||||
sc_file_free(*file_out);
|
|
||||||
*file_out = file;
|
*file_out = file;
|
||||||
dnie_free_apdu_buffers(&apdu, rbuf, sizeof(rbuf));
|
dnie_free_apdu_buffers(&apdu, rbuf, sizeof(rbuf));
|
||||||
LOG_FUNC_RETURN(ctx, res);
|
LOG_FUNC_RETURN(ctx, res);
|
||||||
|
|
|
@ -498,11 +498,8 @@ static int entersafe_select_fid(sc_card_t *card,
|
||||||
path.len=2;
|
path.len=2;
|
||||||
|
|
||||||
r = iso_ops->select_file(card,&path,&file);
|
r = iso_ops->select_file(card,&path,&file);
|
||||||
if(r && file)
|
if (r)
|
||||||
{
|
sc_file_free(file);
|
||||||
if(file)
|
|
||||||
sc_file_free(file);
|
|
||||||
}
|
|
||||||
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed");
|
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed");
|
||||||
|
|
||||||
/* update cache */
|
/* update cache */
|
||||||
|
@ -520,14 +517,9 @@ static int entersafe_select_fid(sc_card_t *card,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_out)
|
if (file_out)
|
||||||
{
|
*file_out = file;
|
||||||
*file_out = file;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
sc_file_free(file);
|
||||||
if(file)
|
|
||||||
sc_file_free(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -288,11 +288,11 @@ iasecc_select_mf(struct sc_card *card, struct sc_file **file_out)
|
||||||
mf_file->type = SC_FILE_TYPE_DF;
|
mf_file->type = SC_FILE_TYPE_DF;
|
||||||
mf_file->path = path;
|
mf_file->path = path;
|
||||||
|
|
||||||
if (card->cache.valid && card->cache.current_df)
|
if (card->cache.valid)
|
||||||
sc_file_free(card->cache.current_df);
|
sc_file_free(card->cache.current_df);
|
||||||
card->cache.current_df = NULL;
|
card->cache.current_df = NULL;
|
||||||
|
|
||||||
if (card->cache.valid && card->cache.current_ef)
|
if (card->cache.valid)
|
||||||
sc_file_free(card->cache.current_ef);
|
sc_file_free(card->cache.current_ef);
|
||||||
card->cache.current_ef = NULL;
|
card->cache.current_ef = NULL;
|
||||||
|
|
||||||
|
@ -895,7 +895,7 @@ iasecc_select_file(struct sc_card *card, const struct sc_path *path,
|
||||||
|
|
||||||
if (file_out)
|
if (file_out)
|
||||||
*file_out = file;
|
*file_out = file;
|
||||||
else if (file)
|
else
|
||||||
sc_file_free(file);
|
sc_file_free(file);
|
||||||
|
|
||||||
if (lpath.type == SC_PATH_TYPE_DF_NAME)
|
if (lpath.type == SC_PATH_TYPE_DF_NAME)
|
||||||
|
@ -915,8 +915,7 @@ iasecc_select_file(struct sc_card *card, const struct sc_path *path,
|
||||||
&& !memcmp(card->cache.current_df->path.value, lpath.value, lpath.len)) {
|
&& !memcmp(card->cache.current_df->path.value, lpath.value, lpath.len)) {
|
||||||
sc_log(ctx, "returns current DF path %s", sc_print_path(&card->cache.current_df->path));
|
sc_log(ctx, "returns current DF path %s", sc_print_path(&card->cache.current_df->path));
|
||||||
if (file_out) {
|
if (file_out) {
|
||||||
if (*file_out)
|
sc_file_free(*file_out);
|
||||||
sc_file_free(*file_out);
|
|
||||||
sc_file_dup(file_out, card->cache.current_df);
|
sc_file_dup(file_out, card->cache.current_df);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1010,7 +1009,7 @@ iasecc_select_file(struct sc_card *card, const struct sc_path *path,
|
||||||
if (rv == SC_ERROR_FILE_NOT_FOUND && cache_valid && df_from_cache) {
|
if (rv == SC_ERROR_FILE_NOT_FOUND && cache_valid && df_from_cache) {
|
||||||
card->cache.valid = 0;
|
card->cache.valid = 0;
|
||||||
sc_log(ctx, "iasecc_select_file() file not found, retry without cached DF");
|
sc_log(ctx, "iasecc_select_file() file not found, retry without cached DF");
|
||||||
if (file_out && *file_out) {
|
if (file_out) {
|
||||||
sc_file_free(*file_out);
|
sc_file_free(*file_out);
|
||||||
*file_out = NULL;
|
*file_out = NULL;
|
||||||
}
|
}
|
||||||
|
@ -1042,12 +1041,12 @@ iasecc_select_file(struct sc_card *card, const struct sc_path *path,
|
||||||
|
|
||||||
sc_log(ctx, "FileType %i", file->type);
|
sc_log(ctx, "FileType %i", file->type);
|
||||||
if (file->type == SC_FILE_TYPE_DF) {
|
if (file->type == SC_FILE_TYPE_DF) {
|
||||||
if (card->cache.valid && card->cache.current_df)
|
if (card->cache.valid)
|
||||||
sc_file_free(card->cache.current_df);
|
sc_file_free(card->cache.current_df);
|
||||||
card->cache.current_df = NULL;
|
card->cache.current_df = NULL;
|
||||||
|
|
||||||
|
|
||||||
if (card->cache.valid && card->cache.current_ef)
|
if (card->cache.valid)
|
||||||
sc_file_free(card->cache.current_ef);
|
sc_file_free(card->cache.current_ef);
|
||||||
card->cache.current_ef = NULL;
|
card->cache.current_ef = NULL;
|
||||||
|
|
||||||
|
@ -1055,7 +1054,7 @@ iasecc_select_file(struct sc_card *card, const struct sc_path *path,
|
||||||
card->cache.valid = 1;
|
card->cache.valid = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (card->cache.valid && card->cache.current_ef)
|
if (card->cache.valid)
|
||||||
sc_file_free(card->cache.current_ef);
|
sc_file_free(card->cache.current_ef);
|
||||||
|
|
||||||
card->cache.current_ef = NULL;
|
card->cache.current_ef = NULL;
|
||||||
|
@ -1064,8 +1063,7 @@ iasecc_select_file(struct sc_card *card, const struct sc_path *path,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_out) {
|
if (file_out) {
|
||||||
if (*file_out)
|
sc_file_free(*file_out);
|
||||||
sc_file_free(*file_out);
|
|
||||||
*file_out = file;
|
*file_out = file;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1073,12 +1071,10 @@ iasecc_select_file(struct sc_card *card, const struct sc_path *path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (lpath.type == SC_PATH_TYPE_DF_NAME) {
|
else if (lpath.type == SC_PATH_TYPE_DF_NAME) {
|
||||||
if (card->cache.current_df)
|
sc_file_free(card->cache.current_df);
|
||||||
sc_file_free(card->cache.current_df);
|
|
||||||
card->cache.current_df = NULL;
|
card->cache.current_df = NULL;
|
||||||
|
|
||||||
if (card->cache.current_ef)
|
sc_file_free(card->cache.current_ef);
|
||||||
sc_file_free(card->cache.current_ef);
|
|
||||||
card->cache.current_ef = NULL;
|
card->cache.current_ef = NULL;
|
||||||
|
|
||||||
card->cache.valid = 1;
|
card->cache.valid = 1;
|
||||||
|
@ -1388,8 +1384,7 @@ iasecc_finish(struct sc_card *card)
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
|
||||||
while (se_info) {
|
while (se_info) {
|
||||||
if (se_info->df)
|
sc_file_free(se_info->df);
|
||||||
sc_file_free(se_info->df);
|
|
||||||
next = se_info->next;
|
next = se_info->next;
|
||||||
free(se_info);
|
free(se_info);
|
||||||
se_info = next;
|
se_info = next;
|
||||||
|
@ -1436,7 +1431,7 @@ iasecc_delete_file(struct sc_card *card, const struct sc_path *path)
|
||||||
rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
|
rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
|
||||||
LOG_TEST_RET(ctx, rv, "Delete file failed");
|
LOG_TEST_RET(ctx, rv, "Delete file failed");
|
||||||
|
|
||||||
if (card->cache.valid && card->cache.current_ef)
|
if (card->cache.valid)
|
||||||
sc_file_free(card->cache.current_ef);
|
sc_file_free(card->cache.current_ef);
|
||||||
card->cache.current_ef = NULL;
|
card->cache.current_ef = NULL;
|
||||||
}
|
}
|
||||||
|
@ -1916,8 +1911,7 @@ iasecc_se_at_to_chv_reference(struct sc_card *card, unsigned reference,
|
||||||
if (chv_reference)
|
if (chv_reference)
|
||||||
*chv_reference = crt.refs[0];
|
*chv_reference = crt.refs[0];
|
||||||
|
|
||||||
if (se.df)
|
sc_file_free(se.df);
|
||||||
sc_file_free(se.df);
|
|
||||||
|
|
||||||
LOG_FUNC_RETURN(ctx, rv);
|
LOG_FUNC_RETURN(ctx, rv);
|
||||||
}
|
}
|
||||||
|
@ -2211,8 +2205,7 @@ iasecc_pin_get_policy (struct sc_card *card, struct sc_pin_cmd_data *data)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (se.df)
|
sc_file_free(se.df);
|
||||||
sc_file_free(se.df);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sdo.data.chv.size_max.value)
|
if (sdo.data.chv.size_max.value)
|
||||||
|
@ -2977,8 +2970,7 @@ iasecc_get_chv_reference_from_se(struct sc_card *card, int *se_reference)
|
||||||
rv = iasecc_se_get_crt(card, &se, &crt);
|
rv = iasecc_se_get_crt(card, &se, &crt);
|
||||||
LOG_TEST_RET(ctx, rv, "Cannot get 'USER PASSWORD' authentication template");
|
LOG_TEST_RET(ctx, rv, "Cannot get 'USER PASSWORD' authentication template");
|
||||||
|
|
||||||
if (se.df)
|
sc_file_free(se.df);
|
||||||
sc_file_free(se.df);
|
|
||||||
LOG_FUNC_RETURN(ctx, crt.refs[0]);
|
LOG_FUNC_RETURN(ctx, crt.refs[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -491,8 +491,7 @@ auth_select_file(struct sc_card *card, const struct sc_path *in_path,
|
||||||
auth_current_ef->path.type, sc_print_path(&auth_current_ef->path));
|
auth_current_ef->path.type, sc_print_path(&auth_current_ef->path));
|
||||||
|
|
||||||
if (path.type == SC_PATH_TYPE_PARENT || path.type == SC_PATH_TYPE_FILE_ID) {
|
if (path.type == SC_PATH_TYPE_PARENT || path.type == SC_PATH_TYPE_FILE_ID) {
|
||||||
if (auth_current_ef)
|
sc_file_free(auth_current_ef);
|
||||||
sc_file_free(auth_current_ef);
|
|
||||||
auth_current_ef = NULL;
|
auth_current_ef = NULL;
|
||||||
|
|
||||||
rv = iso_ops->select_file(card, &path, &tmp_file);
|
rv = iso_ops->select_file(card, &path, &tmp_file);
|
||||||
|
@ -516,8 +515,7 @@ auth_select_file(struct sc_card *card, const struct sc_path *in_path,
|
||||||
sc_file_dup(&auth_current_df, tmp_file);
|
sc_file_dup(&auth_current_df, tmp_file);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (auth_current_ef)
|
sc_file_free(auth_current_ef);
|
||||||
sc_file_free(auth_current_ef);
|
|
||||||
|
|
||||||
sc_file_dup(&auth_current_ef, tmp_file);
|
sc_file_dup(&auth_current_ef, tmp_file);
|
||||||
sc_concatenate_path(&auth_current_ef->path, &auth_current_df->path, &path);
|
sc_concatenate_path(&auth_current_ef->path, &auth_current_df->path, &path);
|
||||||
|
@ -531,8 +529,7 @@ auth_select_file(struct sc_card *card, const struct sc_path *in_path,
|
||||||
else if (path.type == SC_PATH_TYPE_DF_NAME) {
|
else if (path.type == SC_PATH_TYPE_DF_NAME) {
|
||||||
rv = iso_ops->select_file(card, &path, NULL);
|
rv = iso_ops->select_file(card, &path, NULL);
|
||||||
if (rv) {
|
if (rv) {
|
||||||
if (auth_current_ef)
|
sc_file_free(auth_current_ef);
|
||||||
sc_file_free(auth_current_ef);
|
|
||||||
auth_current_ef = NULL;
|
auth_current_ef = NULL;
|
||||||
}
|
}
|
||||||
LOG_TEST_RET(card->ctx, rv, "select file failed");
|
LOG_TEST_RET(card->ctx, rv, "select file failed");
|
||||||
|
@ -993,8 +990,7 @@ auth_create_file(struct sc_card *card, struct sc_file *file)
|
||||||
sc_log(card->ctx, "rv %i", rv);
|
sc_log(card->ctx, "rv %i", rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auth_current_ef)
|
sc_file_free(auth_current_ef);
|
||||||
sc_file_free(auth_current_ef);
|
|
||||||
sc_file_dup(&auth_current_ef, file);
|
sc_file_dup(&auth_current_ef, file);
|
||||||
|
|
||||||
LOG_FUNC_RETURN(card->ctx, rv);
|
LOG_FUNC_RETURN(card->ctx, rv);
|
||||||
|
|
|
@ -790,8 +790,7 @@ pgp_free_blob(pgp_blob_t *blob)
|
||||||
*p = blob->next;
|
*p = blob->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blob->file)
|
sc_file_free(blob->file);
|
||||||
sc_file_free(blob->file);
|
|
||||||
if (blob->data)
|
if (blob->data)
|
||||||
free(blob->data);
|
free(blob->data);
|
||||||
free(blob);
|
free(blob);
|
||||||
|
|
|
@ -2853,8 +2853,7 @@ piv_finish(sc_card_t *card)
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
|
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
|
||||||
if (priv) {
|
if (priv) {
|
||||||
if (priv->aid_file)
|
sc_file_free(priv->aid_file);
|
||||||
sc_file_free(priv->aid_file);
|
|
||||||
if (priv->w_buf)
|
if (priv->w_buf)
|
||||||
free(priv->w_buf);
|
free(priv->w_buf);
|
||||||
if (priv->offCardCertURL)
|
if (priv->offCardCertURL)
|
||||||
|
|
|
@ -86,9 +86,7 @@ static int sc_hsm_select_file(sc_card_t *card,
|
||||||
|
|
||||||
if (file_out == NULL) { // Versions before 0.16 of the SmartCard-HSM do not support P2='0C'
|
if (file_out == NULL) { // Versions before 0.16 of the SmartCard-HSM do not support P2='0C'
|
||||||
rv = sc_hsm_select_file(card, in_path, &file);
|
rv = sc_hsm_select_file(card, in_path, &file);
|
||||||
if (file != NULL) {
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
}
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1238,8 +1238,7 @@ out:
|
||||||
RSA_free(rsa);
|
RSA_free(rsa);
|
||||||
out2:
|
out2:
|
||||||
#endif /* ENABLE_OPENSSL */
|
#endif /* ENABLE_OPENSSL */
|
||||||
if (keyfile)
|
sc_file_free(keyfile);
|
||||||
sc_file_free(keyfile);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,8 +98,7 @@ static void sc_card_free(sc_card_t *card)
|
||||||
sc_free_apps(card);
|
sc_free_apps(card);
|
||||||
sc_free_ef_atr(card);
|
sc_free_ef_atr(card);
|
||||||
|
|
||||||
if (card->ef_dir != NULL)
|
sc_file_free(card->ef_dir);
|
||||||
sc_file_free(card->ef_dir);
|
|
||||||
|
|
||||||
free(card->ops);
|
free(card->ops);
|
||||||
|
|
||||||
|
@ -120,11 +119,8 @@ static void sc_card_free(sc_card_t *card)
|
||||||
card->algorithm_count = 0;
|
card->algorithm_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (card->cache.current_ef)
|
sc_file_free(card->cache.current_ef);
|
||||||
sc_file_free(card->cache.current_ef);
|
sc_file_free(card->cache.current_df);
|
||||||
|
|
||||||
if (card->cache.current_df)
|
|
||||||
sc_file_free(card->cache.current_df);
|
|
||||||
|
|
||||||
if (card->mutex != NULL) {
|
if (card->mutex != NULL) {
|
||||||
int r = sc_mutex_destroy(card->ctx, card->mutex);
|
int r = sc_mutex_destroy(card->ctx, card->mutex);
|
||||||
|
|
|
@ -348,7 +348,7 @@ int dnie_read_file(sc_card_t * card,
|
||||||
dnie_read_file_err:
|
dnie_read_file_err:
|
||||||
if (data)
|
if (data)
|
||||||
free(data);
|
free(data);
|
||||||
if (file && *file) {
|
if (file) {
|
||||||
sc_file_free(*file);
|
sc_file_free(*file);
|
||||||
*file = NULL;
|
*file = NULL;
|
||||||
}
|
}
|
||||||
|
@ -400,10 +400,8 @@ static int dnie_read_certificate(sc_card_t * card, char *certpath, X509 ** cert)
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
bufferlen = 0;
|
bufferlen = 0;
|
||||||
}
|
}
|
||||||
if (file) {
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
file = NULL;
|
||||||
file = NULL;
|
|
||||||
}
|
|
||||||
if (msg)
|
if (msg)
|
||||||
sc_log(card->ctx, msg);
|
sc_log(card->ctx, msg);
|
||||||
LOG_FUNC_RETURN(card->ctx, res);
|
LOG_FUNC_RETURN(card->ctx, res);
|
||||||
|
|
|
@ -165,10 +165,8 @@ int sc_enum_apps(sc_card_t *card)
|
||||||
card->app_count = 0;
|
card->app_count = 0;
|
||||||
|
|
||||||
sc_format_path("3F002F00", &path);
|
sc_format_path("3F002F00", &path);
|
||||||
if (card->ef_dir != NULL) {
|
sc_file_free(card->ef_dir);
|
||||||
sc_file_free(card->ef_dir);
|
card->ef_dir = NULL;
|
||||||
card->ef_dir = NULL;
|
|
||||||
}
|
|
||||||
r = sc_select_file(card, &path, &card->ef_dir);
|
r = sc_select_file(card, &path, &card->ef_dir);
|
||||||
LOG_TEST_RET(ctx, r, "Cannot select EF.DIR file");
|
LOG_TEST_RET(ctx, r, "Cannot select EF.DIR file");
|
||||||
|
|
||||||
|
|
|
@ -236,8 +236,7 @@ iasecc_sm_se_mutual_authentication(struct sc_card *card, unsigned se_num)
|
||||||
rv = iasecc_se_get_crt(card, &se, crt);
|
rv = iasecc_se_get_crt(card, &se, crt);
|
||||||
LOG_TEST_RET(ctx, rv, "Cannot get authentication CRT");
|
LOG_TEST_RET(ctx, rv, "Cannot get authentication CRT");
|
||||||
|
|
||||||
if (se.df)
|
sc_file_free(se.df);
|
||||||
sc_file_free(se.df);
|
|
||||||
|
|
||||||
/* MSE SET Mutual Authentication SK scheme */
|
/* MSE SET Mutual Authentication SK scheme */
|
||||||
offs = 0;
|
offs = 0;
|
||||||
|
|
|
@ -46,8 +46,7 @@ int dump_ef(sc_card_t * card, const char *path, u8 * buf, size_t * buf_len)
|
||||||
sc_format_path(path, &scpath);
|
sc_format_path(path, &scpath);
|
||||||
rv = sc_select_file(card, &scpath, &file);
|
rv = sc_select_file(card, &scpath, &file);
|
||||||
if (rv < 0) {
|
if (rv < 0) {
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
if (file->size > *buf_len) {
|
if (file->size > *buf_len) {
|
||||||
|
|
|
@ -243,8 +243,7 @@ static int infocamere_1200_init(sc_pkcs15_card_t * p15card)
|
||||||
|
|
||||||
if (r != SC_SUCCESS || file->size > 255) {
|
if (r != SC_SUCCESS || file->size > 255) {
|
||||||
/* Not EF.GDO */
|
/* Not EF.GDO */
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
return SC_ERROR_WRONG_CARD;
|
return SC_ERROR_WRONG_CARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,7 @@ int dump_ef(sc_card_t * card, const char *path, u8 * buf, size_t * buf_len)
|
||||||
sc_format_path(path, &scpath);
|
sc_format_path(path, &scpath);
|
||||||
rv = sc_select_file(card, &scpath, &file);
|
rv = sc_select_file(card, &scpath, &file);
|
||||||
if (rv < 0) {
|
if (rv < 0) {
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
if (file->size > *buf_len) {
|
if (file->size > *buf_len) {
|
||||||
|
|
|
@ -406,14 +406,10 @@ fix_authentic_ddo(struct sc_pkcs15_card *p15card)
|
||||||
* Cleanup this attributes -- default values must be OK.
|
* Cleanup this attributes -- default values must be OK.
|
||||||
*/
|
*/
|
||||||
if (p15card->card->type == SC_CARD_TYPE_OBERTHUR_AUTHENTIC_3_2) {
|
if (p15card->card->type == SC_CARD_TYPE_OBERTHUR_AUTHENTIC_3_2) {
|
||||||
if (p15card->file_odf != NULL) {
|
sc_file_free(p15card->file_odf);
|
||||||
sc_file_free(p15card->file_odf);
|
p15card->file_odf = NULL;
|
||||||
p15card->file_odf = NULL;
|
sc_file_free(p15card->file_tokeninfo);
|
||||||
}
|
p15card->file_tokeninfo = NULL;
|
||||||
if (p15card->file_tokeninfo != NULL) {
|
|
||||||
sc_file_free(p15card->file_tokeninfo);
|
|
||||||
p15card->file_tokeninfo = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,18 +514,12 @@ parse_ddo(struct sc_pkcs15_card *p15card, const u8 * buf, size_t buflen)
|
||||||
fix_authentic_ddo(p15card);
|
fix_authentic_ddo(p15card);
|
||||||
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
||||||
mem_err:
|
mem_err:
|
||||||
if (p15card->file_odf != NULL) {
|
sc_file_free(p15card->file_odf);
|
||||||
sc_file_free(p15card->file_odf);
|
p15card->file_odf = NULL;
|
||||||
p15card->file_odf = NULL;
|
sc_file_free(p15card->file_tokeninfo);
|
||||||
}
|
p15card->file_tokeninfo = NULL;
|
||||||
if (p15card->file_tokeninfo != NULL) {
|
sc_file_free(p15card->file_unusedspace);
|
||||||
sc_file_free(p15card->file_tokeninfo);
|
p15card->file_unusedspace = NULL;
|
||||||
p15card->file_tokeninfo = NULL;
|
|
||||||
}
|
|
||||||
if (p15card->file_unusedspace != NULL) {
|
|
||||||
sc_file_free(p15card->file_unusedspace);
|
|
||||||
p15card->file_unusedspace = NULL;
|
|
||||||
}
|
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -794,14 +784,10 @@ sc_pkcs15_card_free(struct sc_pkcs15_card *p15card)
|
||||||
sc_pkcs15_free_unusedspace(p15card);
|
sc_pkcs15_free_unusedspace(p15card);
|
||||||
p15card->unusedspace_read = 0;
|
p15card->unusedspace_read = 0;
|
||||||
|
|
||||||
if (p15card->file_app != NULL)
|
sc_file_free(p15card->file_app);
|
||||||
sc_file_free(p15card->file_app);
|
sc_file_free(p15card->file_tokeninfo);
|
||||||
if (p15card->file_tokeninfo != NULL)
|
sc_file_free(p15card->file_odf);
|
||||||
sc_file_free(p15card->file_tokeninfo);
|
sc_file_free(p15card->file_unusedspace);
|
||||||
if (p15card->file_odf != NULL)
|
|
||||||
sc_file_free(p15card->file_odf);
|
|
||||||
if (p15card->file_unusedspace != NULL)
|
|
||||||
sc_file_free(p15card->file_unusedspace);
|
|
||||||
|
|
||||||
p15card->magic = 0;
|
p15card->magic = 0;
|
||||||
sc_pkcs15_free_tokeninfo(p15card);
|
sc_pkcs15_free_tokeninfo(p15card);
|
||||||
|
@ -827,22 +813,14 @@ sc_pkcs15_card_clear(struct sc_pkcs15_card *p15card)
|
||||||
sc_pkcs15_remove_dfs(p15card);
|
sc_pkcs15_remove_dfs(p15card);
|
||||||
|
|
||||||
p15card->df_list = NULL;
|
p15card->df_list = NULL;
|
||||||
if (p15card->file_app != NULL) {
|
sc_file_free(p15card->file_app);
|
||||||
sc_file_free(p15card->file_app);
|
p15card->file_app = NULL;
|
||||||
p15card->file_app = NULL;
|
sc_file_free(p15card->file_tokeninfo);
|
||||||
}
|
p15card->file_tokeninfo = NULL;
|
||||||
if (p15card->file_tokeninfo != NULL) {
|
sc_file_free(p15card->file_odf);
|
||||||
sc_file_free(p15card->file_tokeninfo);
|
p15card->file_odf = NULL;
|
||||||
p15card->file_tokeninfo = NULL;
|
sc_file_free(p15card->file_unusedspace);
|
||||||
}
|
p15card->file_unusedspace = NULL;
|
||||||
if (p15card->file_odf != NULL) {
|
|
||||||
sc_file_free(p15card->file_odf);
|
|
||||||
p15card->file_odf = NULL;
|
|
||||||
}
|
|
||||||
if (p15card->file_unusedspace != NULL) {
|
|
||||||
sc_file_free(p15card->file_unusedspace);
|
|
||||||
p15card->file_unusedspace = NULL;
|
|
||||||
}
|
|
||||||
if (p15card->tokeninfo->label != NULL) {
|
if (p15card->tokeninfo->label != NULL) {
|
||||||
free(p15card->tokeninfo->label);
|
free(p15card->tokeninfo->label);
|
||||||
p15card->tokeninfo->label = NULL;
|
p15card->tokeninfo->label = NULL;
|
||||||
|
@ -2433,8 +2411,7 @@ sc_pkcs15_read_file(struct sc_pkcs15_card *p15card, const struct sc_path *in_pat
|
||||||
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
||||||
|
|
||||||
fail_unlock:
|
fail_unlock:
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
sc_unlock(p15card->card);
|
sc_unlock(p15card->card);
|
||||||
LOG_FUNC_RETURN(ctx, r);
|
LOG_FUNC_RETURN(ctx, r);
|
||||||
}
|
}
|
||||||
|
|
|
@ -542,6 +542,8 @@ sc_file_t * sc_file_new(void)
|
||||||
void sc_file_free(sc_file_t *file)
|
void sc_file_free(sc_file_t *file)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
if (file == NULL)
|
||||||
|
return;
|
||||||
assert(sc_file_valid(file));
|
assert(sc_file_valid(file));
|
||||||
file->magic = 0;
|
file->magic = 0;
|
||||||
for (i = 0; i < SC_MAX_AC_OPS; i++)
|
for (i = 0; i < SC_MAX_AC_OPS; i++)
|
||||||
|
@ -600,8 +602,7 @@ void sc_file_dup(sc_file_t **dest, const sc_file_t *src)
|
||||||
goto err;
|
goto err;
|
||||||
return;
|
return;
|
||||||
err:
|
err:
|
||||||
if (newf != NULL)
|
sc_file_free(newf);
|
||||||
sc_file_free(newf);
|
|
||||||
*dest = NULL;
|
*dest = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -502,8 +502,7 @@ authentic_free_sdo_data(struct sc_authentic_sdo *sdo)
|
||||||
if (!sdo)
|
if (!sdo)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (sdo->file)
|
sc_file_free(sdo->file);
|
||||||
sc_file_free(sdo->file);
|
|
||||||
|
|
||||||
for (ii=0; ii<rsa_mechs_num; ii++)
|
for (ii=0; ii<rsa_mechs_num; ii++)
|
||||||
if (sdo->docp.mech == authentic_v3_rsa_mechs[ii])
|
if (sdo->docp.mech == authentic_v3_rsa_mechs[ii])
|
||||||
|
@ -737,8 +736,7 @@ authentic_pkcs15_delete_rsa_sdo (struct sc_profile *profile, struct sc_pkcs15_ca
|
||||||
LOG_TEST_GOTO_ERR(ctx, rv, "SC_CARDCTL_AUTHENTIC_SDO_DELETE failed for private key");
|
LOG_TEST_GOTO_ERR(ctx, rv, "SC_CARDCTL_AUTHENTIC_SDO_DELETE failed for private key");
|
||||||
|
|
||||||
err:
|
err:
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
LOG_FUNC_RETURN(ctx, rv);
|
LOG_FUNC_RETURN(ctx, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,8 +114,7 @@ static int cflex_erase_card(struct sc_profile *profile, sc_pkcs15_card_t *p15car
|
||||||
|
|
||||||
|
|
||||||
out: /* Forget all cached keys, the pin files on card are all gone. */
|
out: /* Forget all cached keys, the pin files on card are all gone. */
|
||||||
if (userpinfile)
|
sc_file_free(userpinfile);
|
||||||
sc_file_free(userpinfile);
|
|
||||||
|
|
||||||
sc_free_apps(p15card->card);
|
sc_free_apps(p15card->card);
|
||||||
if (r == SC_ERROR_FILE_NOT_FOUND)
|
if (r == SC_ERROR_FILE_NOT_FOUND)
|
||||||
|
@ -308,10 +307,8 @@ cflex_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_pkcs15_obj
|
||||||
|
|
||||||
key_info->key_reference = 0;
|
key_info->key_reference = 0;
|
||||||
|
|
||||||
out: if (prkf)
|
out: sc_file_free(prkf);
|
||||||
sc_file_free(prkf);
|
sc_file_free(pukf);
|
||||||
if (pukf)
|
|
||||||
sc_file_free(pukf);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,10 +369,8 @@ cflex_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
|
||||||
|
|
||||||
invert_buf(pubkey->u.rsa.modulus.data, raw_pubkey, pubkey->u.rsa.modulus.len);
|
invert_buf(pubkey->u.rsa.modulus.data, raw_pubkey, pubkey->u.rsa.modulus.len);
|
||||||
|
|
||||||
out: if (pukf)
|
out: sc_file_free(pukf);
|
||||||
sc_file_free(pukf);
|
sc_file_free(prkf);
|
||||||
if (prkf)
|
|
||||||
sc_file_free(prkf);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -624,12 +624,9 @@ static int epass2003_pkcs15_generate_key(struct sc_profile *profile,
|
||||||
free(gendat.modulus);
|
free(gendat.modulus);
|
||||||
|
|
||||||
err:
|
err:
|
||||||
if (pukf)
|
sc_file_free(pukf);
|
||||||
sc_file_free(pukf);
|
sc_file_free(file);
|
||||||
if (file)
|
sc_file_free(tfile);
|
||||||
sc_file_free(file);
|
|
||||||
if (tfile)
|
|
||||||
sc_file_free(tfile);
|
|
||||||
|
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
|
||||||
}
|
}
|
||||||
|
|
|
@ -500,8 +500,7 @@ gpk_store_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
|
||||||
if (r >= 0)
|
if (r >= 0)
|
||||||
r = gpk_store_pk(profile, p15card, keyfile, &data);
|
r = gpk_store_pk(profile, p15card, keyfile, &data);
|
||||||
|
|
||||||
if (keyfile)
|
sc_file_free(keyfile);
|
||||||
sc_file_free(keyfile);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,8 +594,7 @@ gpk_pkfile_create(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_file_t *f
|
||||||
if (r >= 0)
|
if (r >= 0)
|
||||||
r = sc_pkcs15init_authenticate(profile, p15card, file,
|
r = sc_pkcs15init_authenticate(profile, p15card, file,
|
||||||
SC_AC_OP_UPDATE);
|
SC_AC_OP_UPDATE);
|
||||||
if (found)
|
sc_file_free(found);
|
||||||
sc_file_free(found);
|
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -727,8 +725,7 @@ gpk_pkfile_init_public(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_file
|
||||||
r = sc_append_record(p15card->card, sysrec, sizeof(sysrec), 0);
|
r = sc_append_record(p15card->card, sysrec, sizeof(sysrec), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
out: if (tmp)
|
out: sc_file_free(tmp);
|
||||||
sc_file_free(tmp);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -300,8 +300,7 @@ iasecc_pkcs15_select_key_reference(struct sc_profile *profile, struct sc_pkcs15_
|
||||||
key_info->key_reference = idx | IASECC_OBJECT_REF_LOCAL;
|
key_info->key_reference = idx | IASECC_OBJECT_REF_LOCAL;
|
||||||
sc_log(ctx, "selected key reference %i", key_info->key_reference);
|
sc_log(ctx, "selected key reference %i", key_info->key_reference);
|
||||||
|
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +375,7 @@ iasecc_sdo_set_key_acls_from_profile(struct sc_profile *profile, struct sc_card
|
||||||
|
|
||||||
/* Convert PKCS15 ACLs to SE ACLs */
|
/* Convert PKCS15 ACLs to SE ACLs */
|
||||||
rv = iasecc_file_convert_acls(ctx, profile, file);
|
rv = iasecc_file_convert_acls(ctx, profile, file);
|
||||||
if (rv < 0 && file)
|
if (rv < 0)
|
||||||
sc_file_free(file);
|
sc_file_free(file);
|
||||||
LOG_TEST_RET(ctx, rv, "Cannot convert profile ACLs");
|
LOG_TEST_RET(ctx, rv, "Cannot convert profile ACLs");
|
||||||
|
|
||||||
|
@ -401,8 +400,7 @@ iasecc_sdo_set_key_acls_from_profile(struct sc_profile *profile, struct sc_card
|
||||||
}
|
}
|
||||||
else if (acl->method == SC_AC_SEN || acl->method == SC_AC_PRO || acl->method == SC_AC_AUT) {
|
else if (acl->method == SC_AC_SEN || acl->method == SC_AC_PRO || acl->method == SC_AC_AUT) {
|
||||||
if ((acl->key_ref & 0xF) == 0 || (acl->key_ref & 0xF) == 0xF) {
|
if ((acl->key_ref & 0xF) == 0 || (acl->key_ref & 0xF) == 0xF) {
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid SE reference");
|
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid SE reference");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,14 +414,12 @@ iasecc_sdo_set_key_acls_from_profile(struct sc_profile *profile, struct sc_card
|
||||||
scb[cntr++] = acl->key_ref | IASECC_SCB_METHOD_EXT_AUTH;
|
scb[cntr++] = acl->key_ref | IASECC_SCB_METHOD_EXT_AUTH;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Unknown SCB method");
|
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Unknown SCB method");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
|
|
||||||
/* Copy ACLs into the DOCP*/
|
/* Copy ACLs into the DOCP*/
|
||||||
sdo->docp.acls_contact.tag = IASECC_DOCP_TAG_ACLS_CONTACT;
|
sdo->docp.acls_contact.tag = IASECC_DOCP_TAG_ACLS_CONTACT;
|
||||||
|
@ -853,8 +849,7 @@ iasecc_sdo_store_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
|
||||||
card->caps &= ~SC_CARD_CAP_USE_FCI_AC;
|
card->caps &= ~SC_CARD_CAP_USE_FCI_AC;
|
||||||
rv = sc_pkcs15init_authenticate(profile, p15card, dummy_file, SC_AC_OP_UPDATE);
|
rv = sc_pkcs15init_authenticate(profile, p15card, dummy_file, SC_AC_OP_UPDATE);
|
||||||
card->caps = caps;
|
card->caps = caps;
|
||||||
if (dummy_file)
|
sc_file_free(dummy_file);
|
||||||
sc_file_free(dummy_file);
|
|
||||||
|
|
||||||
LOG_TEST_RET(ctx, rv, "SDO PRIVATE KEY UPDATE authentication failed");
|
LOG_TEST_RET(ctx, rv, "SDO PRIVATE KEY UPDATE authentication failed");
|
||||||
|
|
||||||
|
@ -1037,12 +1032,9 @@ iasecc_pkcs15_create_key_slot(struct sc_profile *profile, struct sc_pkcs15_card
|
||||||
LOG_TEST_GOTO_ERR(ctx, rv, "create key slot: cannot create public key: ctl failed");
|
LOG_TEST_GOTO_ERR(ctx, rv, "create key slot: cannot create public key: ctl failed");
|
||||||
|
|
||||||
err:
|
err:
|
||||||
if (file_p_prvkey)
|
sc_file_free(file_p_prvkey);
|
||||||
sc_file_free(file_p_prvkey);
|
sc_file_free(file_p_pubkey);
|
||||||
if (file_p_pubkey)
|
sc_file_free(parent);
|
||||||
sc_file_free(file_p_pubkey);
|
|
||||||
if (parent)
|
|
||||||
sc_file_free(parent);
|
|
||||||
|
|
||||||
LOG_FUNC_RETURN(ctx, rv);
|
LOG_FUNC_RETURN(ctx, rv);
|
||||||
}
|
}
|
||||||
|
@ -1141,8 +1133,7 @@ iasecc_pkcs15_generate_key(struct sc_profile *profile, sc_pkcs15_card_t *p15card
|
||||||
rv = sc_select_file(card, &file->path, NULL);
|
rv = sc_select_file(card, &file->path, NULL);
|
||||||
LOG_TEST_RET(ctx, rv, "DF for private objects not defined");
|
LOG_TEST_RET(ctx, rv, "DF for private objects not defined");
|
||||||
|
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
|
|
||||||
rv = iasecc_sdo_convert_to_file(card, sdo_prvkey, &file);
|
rv = iasecc_sdo_convert_to_file(card, sdo_prvkey, &file);
|
||||||
LOG_TEST_RET(ctx, rv, "Cannot convert SDO PRIVKEY to file");
|
LOG_TEST_RET(ctx, rv, "Cannot convert SDO PRIVKEY to file");
|
||||||
|
@ -1234,8 +1225,7 @@ iasecc_pkcs15_store_key(struct sc_profile *profile, struct sc_pkcs15_card *p15ca
|
||||||
rv = sc_select_file(card, &file->path, NULL);
|
rv = sc_select_file(card, &file->path, NULL);
|
||||||
LOG_TEST_RET(ctx, rv, "failed to select parent DF");
|
LOG_TEST_RET(ctx, rv, "failed to select parent DF");
|
||||||
|
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
|
|
||||||
key_info->access_flags &= ~SC_PKCS15_PRKEY_ACCESS_LOCAL;
|
key_info->access_flags &= ~SC_PKCS15_PRKEY_ACCESS_LOCAL;
|
||||||
|
|
||||||
|
@ -1303,8 +1293,7 @@ iasecc_pkcs15_delete_sdo (struct sc_profile *profile, struct sc_pkcs15_card *p15
|
||||||
rv = sc_pkcs15init_authenticate(profile, p15card, dummy_file, SC_AC_OP_UPDATE);
|
rv = sc_pkcs15init_authenticate(profile, p15card, dummy_file, SC_AC_OP_UPDATE);
|
||||||
card->caps = save_card_caps;
|
card->caps = save_card_caps;
|
||||||
|
|
||||||
if (dummy_file)
|
sc_file_free(dummy_file);
|
||||||
sc_file_free(dummy_file);
|
|
||||||
|
|
||||||
if (rv < 0) {
|
if (rv < 0) {
|
||||||
iasecc_sdo_free(card, sdo);
|
iasecc_sdo_free(card, sdo);
|
||||||
|
@ -1692,8 +1681,7 @@ iasecc_store_cert(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
||||||
rv = iasecc_pkcs15_fix_file_access(p15card, pfile, object);
|
rv = iasecc_pkcs15_fix_file_access(p15card, pfile, object);
|
||||||
LOG_TEST_RET(ctx, rv, "encode file access rules failed");
|
LOG_TEST_RET(ctx, rv, "encode file access rules failed");
|
||||||
|
|
||||||
if (pfile)
|
sc_file_free(pfile);
|
||||||
sc_file_free(pfile);
|
|
||||||
|
|
||||||
/* NOT_IMPLEMENTED error code indicates to the upper call to execute the default 'store data' procedure */
|
/* NOT_IMPLEMENTED error code indicates to the upper call to execute the default 'store data' procedure */
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_IMPLEMENTED);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_IMPLEMENTED);
|
||||||
|
@ -1801,13 +1789,9 @@ iasecc_store_data_object(struct sc_pkcs15_card *p15card, struct sc_profile *prof
|
||||||
if (path)
|
if (path)
|
||||||
*path = file->path;
|
*path = file->path;
|
||||||
|
|
||||||
if (parent)
|
sc_file_free(parent);
|
||||||
sc_file_free(parent);
|
|
||||||
|
|
||||||
sc_file_free(file);
|
sc_file_free(file);
|
||||||
|
sc_file_free(cfile);
|
||||||
if (cfile)
|
|
||||||
sc_file_free(cfile);
|
|
||||||
|
|
||||||
LOG_FUNC_RETURN(ctx, rv);
|
LOG_FUNC_RETURN(ctx, rv);
|
||||||
#undef MAX_DATA_OBJS
|
#undef MAX_DATA_OBJS
|
||||||
|
|
|
@ -324,10 +324,8 @@ jcop_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
|
||||||
free(keybuf);
|
free(keybuf);
|
||||||
if (delete_ok)
|
if (delete_ok)
|
||||||
sc_pkcs15init_rmdir(p15card, profile, temppubfile);
|
sc_pkcs15init_rmdir(p15card, profile, temppubfile);
|
||||||
if (keyfile)
|
sc_file_free(keyfile);
|
||||||
sc_file_free(keyfile);
|
sc_file_free(temppubfile);
|
||||||
if (temppubfile)
|
|
||||||
sc_file_free(temppubfile);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -467,8 +467,7 @@ sc_pkcs15init_set_p15card(struct sc_profile *profile, struct sc_pkcs15_card *p15
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
profile->p15_data = p15card;
|
profile->p15_data = p15card;
|
||||||
|
@ -2842,8 +2841,7 @@ sc_pkcs15init_update_any_df(struct sc_pkcs15_card *p15card,
|
||||||
}
|
}
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
|
|
||||||
LOG_TEST_RET(ctx, r, "Failed to encode or update xDF");
|
LOG_TEST_RET(ctx, r, "Failed to encode or update xDF");
|
||||||
|
|
||||||
|
@ -3253,8 +3251,7 @@ sc_pkcs15init_update_certificate(struct sc_pkcs15_card *p15card,
|
||||||
profile->dirty = 1;
|
profile->dirty = 1;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
|
|
||||||
LOG_FUNC_RETURN(ctx, r);
|
LOG_FUNC_RETURN(ctx, r);
|
||||||
}
|
}
|
||||||
|
@ -3545,8 +3542,7 @@ sc_pkcs15init_authenticate(struct sc_profile *profile, struct sc_pkcs15_card *p1
|
||||||
r = sc_pkcs15init_verify_secret(profile, p15card, file_tmp ? file_tmp : file, acl->method, acl->key_ref);
|
r = sc_pkcs15init_verify_secret(profile, p15card, file_tmp ? file_tmp : file, acl->method, acl->key_ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_tmp)
|
sc_file_free(file_tmp);
|
||||||
sc_file_free(file_tmp);
|
|
||||||
|
|
||||||
LOG_FUNC_RETURN(ctx, r);
|
LOG_FUNC_RETURN(ctx, r);
|
||||||
}
|
}
|
||||||
|
@ -3630,8 +3626,7 @@ sc_pkcs15init_create_file(struct sc_profile *profile, struct sc_pkcs15_card *p15
|
||||||
r = sc_create_file(p15card->card, file);
|
r = sc_create_file(p15card->card, file);
|
||||||
LOG_TEST_RET(ctx, r, "Create file failed");
|
LOG_TEST_RET(ctx, r, "Create file failed");
|
||||||
|
|
||||||
if (parent)
|
sc_file_free(parent);
|
||||||
sc_file_free(parent);
|
|
||||||
LOG_FUNC_RETURN(ctx, r);
|
LOG_FUNC_RETURN(ctx, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -185,8 +185,7 @@ myeid_init_card(sc_profile_t *profile,
|
||||||
sc_format_path("3F00", &path);
|
sc_format_path("3F00", &path);
|
||||||
r = sc_select_file(p15card->card, &path, &file);
|
r = sc_select_file(p15card->card, &path, &file);
|
||||||
|
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
|
|
||||||
LOG_FUNC_RETURN(p15card->card->ctx, r);
|
LOG_FUNC_RETURN(p15card->card->ctx, r);
|
||||||
}
|
}
|
||||||
|
@ -231,8 +230,7 @@ myeid_create_dir(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_file_t *df
|
||||||
sc_log(ctx, "Create '%s'", create_dfs[ii]);
|
sc_log(ctx, "Create '%s'", create_dfs[ii]);
|
||||||
|
|
||||||
r = sc_profile_get_file(profile, create_dfs[ii], &file);
|
r = sc_profile_get_file(profile, create_dfs[ii], &file);
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
if (r) {
|
if (r) {
|
||||||
sc_log(ctx, "Inconsistent profile: cannot find %s", create_dfs[ii]);
|
sc_log(ctx, "Inconsistent profile: cannot find %s", create_dfs[ii]);
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INCONSISTENT_PROFILE);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INCONSISTENT_PROFILE);
|
||||||
|
@ -530,8 +528,7 @@ myeid_store_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
|
||||||
r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE);
|
r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE);
|
||||||
LOG_TEST_RET(ctx, r, "No authorisation to store MyEID private key");
|
LOG_TEST_RET(ctx, r, "No authorisation to store MyEID private key");
|
||||||
|
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
|
|
||||||
/* Fill in data structure */
|
/* Fill in data structure */
|
||||||
memset(&args, 0, sizeof (args));
|
memset(&args, 0, sizeof (args));
|
||||||
|
@ -722,8 +719,7 @@ myeid_generate_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
|
|
||||||
LOG_FUNC_RETURN(ctx, r);
|
LOG_FUNC_RETURN(ctx, r);
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,8 +152,7 @@ awp_new_file(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
||||||
if (otag) {
|
if (otag) {
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "obj template %s",otag);
|
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "obj template %s",otag);
|
||||||
if (sc_profile_get_file(profile, otag, &ofile) < 0) {
|
if (sc_profile_get_file(profile, otag, &ofile) < 0) {
|
||||||
if (ifile)
|
sc_file_free(ifile);
|
||||||
sc_file_free(ifile);
|
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "profile does not defines template '%s'", name);
|
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "profile does not defines template '%s'", name);
|
||||||
return SC_ERROR_INCONSISTENT_PROFILE;
|
return SC_ERROR_INCONSISTENT_PROFILE;
|
||||||
}
|
}
|
||||||
|
@ -531,8 +530,8 @@ awp_update_container(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (clist) sc_file_free(clist);
|
sc_file_free(clist);
|
||||||
if (file) sc_file_free(file);
|
sc_file_free(file);
|
||||||
if (list) free(list);
|
if (list) free(list);
|
||||||
|
|
||||||
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
||||||
|
@ -1392,10 +1391,8 @@ awp_update_df_create_cert(struct sc_pkcs15_card *p15card, struct sc_profile *pro
|
||||||
|
|
||||||
awp_free_cert_info(&icert);
|
awp_free_cert_info(&icert);
|
||||||
|
|
||||||
if (info_file)
|
sc_file_free(info_file);
|
||||||
sc_file_free(info_file);
|
sc_file_free(obj_file);
|
||||||
if (obj_file)
|
|
||||||
sc_file_free(obj_file);
|
|
||||||
|
|
||||||
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
||||||
}
|
}
|
||||||
|
@ -1478,8 +1475,7 @@ awp_update_df_create_prvkey(struct sc_pkcs15_card *p15card, struct sc_profile *p
|
||||||
err:
|
err:
|
||||||
if (p15cert)
|
if (p15cert)
|
||||||
sc_pkcs15_free_certificate(p15cert);
|
sc_pkcs15_free_certificate(p15cert);
|
||||||
if (info_file)
|
sc_file_free(info_file);
|
||||||
sc_file_free(info_file);
|
|
||||||
if (cert_obj)
|
if (cert_obj)
|
||||||
awp_free_cert_info(&icert);
|
awp_free_cert_info(&icert);
|
||||||
|
|
||||||
|
@ -1532,8 +1528,7 @@ awp_update_df_create_pubkey(struct sc_pkcs15_card *p15card, struct sc_profile *p
|
||||||
awp_free_key_info(&ikey);
|
awp_free_key_info(&ikey);
|
||||||
|
|
||||||
err:
|
err:
|
||||||
if (info_file)
|
sc_file_free(info_file);
|
||||||
sc_file_free(info_file);
|
|
||||||
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1572,10 +1567,8 @@ awp_update_df_create_data(struct sc_pkcs15_card *p15card, struct sc_profile *pro
|
||||||
|
|
||||||
awp_free_data_info(&idata);
|
awp_free_data_info(&idata);
|
||||||
|
|
||||||
if (info_file)
|
sc_file_free(info_file);
|
||||||
sc_file_free(info_file);
|
sc_file_free(obj_file);
|
||||||
if (obj_file)
|
|
||||||
sc_file_free(obj_file);
|
|
||||||
|
|
||||||
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
||||||
}
|
}
|
||||||
|
@ -1689,8 +1682,8 @@ awp_delete_from_container(struct sc_pkcs15_card *p15card,
|
||||||
if (rv > 0)
|
if (rv > 0)
|
||||||
rv = 0;
|
rv = 0;
|
||||||
|
|
||||||
if (buff) free(buff);
|
free(buff);
|
||||||
if (clist) sc_file_free(clist);
|
sc_file_free(clist);
|
||||||
sc_file_free(file);
|
sc_file_free(file);
|
||||||
|
|
||||||
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
||||||
|
@ -1766,8 +1759,7 @@ done:
|
||||||
if (buff)
|
if (buff)
|
||||||
free(buff);
|
free(buff);
|
||||||
sc_file_free(lst);
|
sc_file_free(lst);
|
||||||
if (lst_file)
|
sc_file_free(lst_file);
|
||||||
sc_file_free(lst_file);
|
|
||||||
|
|
||||||
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,8 +111,7 @@ cosm_write_tokeninfo (struct sc_pkcs15_card *p15card, struct sc_profile *profile
|
||||||
rv = 0;
|
rv = 0;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
free(buffer);
|
free(buffer);
|
||||||
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
||||||
}
|
}
|
||||||
|
@ -322,8 +321,7 @@ cosm_create_reference_data(struct sc_profile *profile, struct sc_pkcs15_card *p1
|
||||||
rv = sc_pkcs15init_update_file(profile, p15card, file, oberthur_puk, sizeof(oberthur_puk));
|
rv = sc_pkcs15init_update_file(profile, p15card, file, oberthur_puk, sizeof(oberthur_puk));
|
||||||
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "Failed to update pukfile");
|
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "Failed to update pukfile");
|
||||||
|
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
||||||
|
@ -714,8 +712,7 @@ cosm_create_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
|
||||||
key_info->key_reference = file->path.value[file->path.len - 1];
|
key_info->key_reference = file->path.value[file->path.len - 1];
|
||||||
|
|
||||||
err:
|
err:
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
|
|
||||||
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
||||||
}
|
}
|
||||||
|
@ -761,8 +758,7 @@ cosm_store_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
|
||||||
rv = sc_card_ctl(p15card->card, SC_CARDCTL_OBERTHUR_UPDATE_KEY, &update_info);
|
rv = sc_card_ctl(p15card->card, SC_CARDCTL_OBERTHUR_UPDATE_KEY, &update_info);
|
||||||
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "Cannot update private key");
|
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "Cannot update private key");
|
||||||
|
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
|
|
||||||
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, rv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,6 @@ static int create_sysdf(sc_profile_t *profile, sc_card_t *card, const char *name
|
||||||
SC_AC_NEVER, SC_AC_KEY_REF_NONE);
|
SC_AC_NEVER, SC_AC_KEY_REF_NONE);
|
||||||
if (r == SC_SUCCESS)
|
if (r == SC_SUCCESS)
|
||||||
r = sc_create_file(card, file);
|
r = sc_create_file(card, file);
|
||||||
assert(file);
|
|
||||||
sc_file_free(file);
|
sc_file_free(file);
|
||||||
}
|
}
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
|
@ -99,7 +98,6 @@ static int rtecp_init(sc_profile_t *profile, sc_pkcs15_card_t *p15card)
|
||||||
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Get MF info failed");
|
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Get MF info failed");
|
||||||
assert(file);
|
assert(file);
|
||||||
r = sc_create_file(card, file);
|
r = sc_create_file(card, file);
|
||||||
assert(file);
|
|
||||||
sc_file_free(file);
|
sc_file_free(file);
|
||||||
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Create MF failed");
|
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Create MF failed");
|
||||||
|
|
||||||
|
@ -107,7 +105,6 @@ static int rtecp_init(sc_profile_t *profile, sc_pkcs15_card_t *p15card)
|
||||||
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Get DIR file info failed");
|
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Get DIR file info failed");
|
||||||
assert(file);
|
assert(file);
|
||||||
r = sc_create_file(card, file);
|
r = sc_create_file(card, file);
|
||||||
assert(file);
|
|
||||||
sc_file_free(file);
|
sc_file_free(file);
|
||||||
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Create DIR file failed");
|
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Create DIR file failed");
|
||||||
|
|
||||||
|
@ -346,7 +343,6 @@ static int rtecp_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
|
||||||
r = sc_file_add_acl_entry(file, SC_AC_OP_CREATE, SC_AC_CHV, auth_id);
|
r = sc_file_add_acl_entry(file, SC_AC_OP_CREATE, SC_AC_CHV, auth_id);
|
||||||
if (r == SC_SUCCESS)
|
if (r == SC_SUCCESS)
|
||||||
r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_CREATE);
|
r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_CREATE);
|
||||||
assert(file);
|
|
||||||
sc_file_free(file);
|
sc_file_free(file);
|
||||||
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "Authenticate failed");
|
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "Authenticate failed");
|
||||||
|
|
||||||
|
@ -403,7 +399,6 @@ static int rtecp_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
|
||||||
sc_log(ctx, "create public key file id:%04i", file->id);
|
sc_log(ctx, "create public key file id:%04i", file->id);
|
||||||
r = sc_create_file(p15card->card, file);
|
r = sc_create_file(p15card->card, file);
|
||||||
}
|
}
|
||||||
assert(file);
|
|
||||||
sc_file_free(file);
|
sc_file_free(file);
|
||||||
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r);
|
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r);
|
||||||
}
|
}
|
||||||
|
|
|
@ -417,8 +417,7 @@ setcos_store_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
|
||||||
r = sc_card_ctl(p15card->card, SC_CARDCTL_SETCOS_GENERATE_STORE_KEY, &args);
|
r = sc_card_ctl(p15card->card, SC_CARDCTL_SETCOS_GENERATE_STORE_KEY, &args);
|
||||||
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "Card control 'GENERATE_STORE_KEY' failed");
|
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "Card control 'GENERATE_STORE_KEY' failed");
|
||||||
|
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
|
|
||||||
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r);
|
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r);
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,8 +117,7 @@ static int westcos_pkcs15_create_pin(sc_profile_t *profile,
|
||||||
if(r) return (r);
|
if(r) return (r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pinfile)
|
sc_file_free(pinfile);
|
||||||
sc_file_free(pinfile);
|
|
||||||
|
|
||||||
if(pin != NULL)
|
if(pin != NULL)
|
||||||
{
|
{
|
||||||
|
@ -314,8 +313,7 @@ out:
|
||||||
BN_free(bn);
|
BN_free(bn);
|
||||||
if(rsa)
|
if(rsa)
|
||||||
RSA_free(rsa);
|
RSA_free(rsa);
|
||||||
if(prkf)
|
sc_file_free(prkf);
|
||||||
sc_file_free(prkf);
|
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -260,8 +260,7 @@ static int usage(int (*func)(int, char **))
|
||||||
|
|
||||||
static void die(int ret)
|
static void die(int ret)
|
||||||
{
|
{
|
||||||
if (current_file != NULL)
|
sc_file_free(current_file);
|
||||||
sc_file_free(current_file);
|
|
||||||
if (card) {
|
if (card) {
|
||||||
sc_unlock(card);
|
sc_unlock(card);
|
||||||
sc_disconnect_card(card);
|
sc_disconnect_card(card);
|
||||||
|
@ -684,8 +683,7 @@ static int do_cd(int argc, char **argv)
|
||||||
printf("unable to go up: %s\n", sc_strerror(r));
|
printf("unable to go up: %s\n", sc_strerror(r));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (current_file)
|
sc_file_free(current_file);
|
||||||
sc_file_free(current_file);
|
|
||||||
current_file = file;
|
current_file = file;
|
||||||
current_path = path;
|
current_path = path;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -705,8 +703,7 @@ static int do_cd(int argc, char **argv)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
current_path = path;
|
current_path = path;
|
||||||
if (current_file)
|
sc_file_free(current_file);
|
||||||
sc_file_free(current_file);
|
|
||||||
current_file = file;
|
current_file = file;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -818,8 +815,7 @@ static int do_cat(int argc, char **argv)
|
||||||
err = 0;
|
err = 0;
|
||||||
err:
|
err:
|
||||||
if (not_current) {
|
if (not_current) {
|
||||||
if (file != NULL)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
select_current_path_or_die();
|
select_current_path_or_die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1318,8 +1314,7 @@ static int do_get(int argc, char **argv)
|
||||||
|
|
||||||
err = 0;
|
err = 0;
|
||||||
err:
|
err:
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
if (outf != NULL && outf != stdout)
|
if (outf != NULL && outf != stdout)
|
||||||
fclose(outf);
|
fclose(outf);
|
||||||
select_current_path_or_die();
|
select_current_path_or_die();
|
||||||
|
@ -1492,8 +1487,7 @@ static int do_put(int argc, char **argv)
|
||||||
|
|
||||||
err = 0;
|
err = 0;
|
||||||
err:
|
err:
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
if (outf)
|
if (outf)
|
||||||
fclose(outf);
|
fclose(outf);
|
||||||
select_current_path_or_die();
|
select_current_path_or_die();
|
||||||
|
@ -1746,8 +1740,7 @@ err:
|
||||||
if (buf)
|
if (buf)
|
||||||
free(buf);
|
free(buf);
|
||||||
if (not_current) {
|
if (not_current) {
|
||||||
if (file)
|
sc_file_free(file);
|
||||||
sc_file_free(file);
|
|
||||||
select_current_path_or_die();
|
select_current_path_or_die();
|
||||||
}
|
}
|
||||||
return -err;
|
return -err;
|
||||||
|
|
Loading…
Reference in New Issue