Allow an empty path in iso7816_delete_file(), to indicate that the current DF should be deleted.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2281 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
9029170d16
commit
6102459d13
|
@ -357,7 +357,7 @@ static int iso7816_process_fci(sc_card_t *card, sc_file_t *file,
|
|||
}
|
||||
name[taglen] = 0;
|
||||
if (ctx->debug >= 3)
|
||||
sc_debug(ctx, "File name: %s\n", name);
|
||||
sc_debug(ctx, " File name: %s\n", name);
|
||||
}
|
||||
tag = sc_asn1_find_tag(ctx, p, len, 0x85, &taglen);
|
||||
if (tag != NULL && taglen) {
|
||||
|
@ -598,15 +598,20 @@ static int iso7816_delete_file(sc_card_t *card, const sc_path_t *path)
|
|||
sc_apdu_t apdu;
|
||||
|
||||
SC_FUNC_CALLED(card->ctx, 1);
|
||||
if (path->type != SC_PATH_TYPE_FILE_ID && path->len != 2) {
|
||||
if (path->type != SC_PATH_TYPE_FILE_ID || (path->len != 0 && path->len != 2)) {
|
||||
sc_error(card->ctx, "File type has to be SC_PATH_TYPE_FILE_ID\n");
|
||||
SC_FUNC_RETURN(card->ctx, 1, SC_ERROR_INVALID_ARGUMENTS);
|
||||
}
|
||||
sbuf[0] = path->value[0];
|
||||
sbuf[1] = path->value[1];
|
||||
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE4, 0x00, 0x00);
|
||||
apdu.lc = 2;
|
||||
apdu.datalen = 2;
|
||||
|
||||
if (path->len == 2) {
|
||||
sbuf[0] = path->value[0];
|
||||
sbuf[1] = path->value[1];
|
||||
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE4, 0x00, 0x00);
|
||||
apdu.lc = 2;
|
||||
apdu.datalen = 2;
|
||||
}
|
||||
else /* No file ID given: means currently selected file */
|
||||
sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0xE4, 0x00, 0x00);
|
||||
apdu.data = sbuf;
|
||||
|
||||
r = sc_transmit_apdu(card, &apdu);
|
||||
|
|
Loading…
Reference in New Issue