handle checking of file output in sc_select_file
fixes https://github.com/OpenSC/OpenSC/issues/576
This commit is contained in:
parent
bcf9b2bc84
commit
e1073c09ea
|
@ -689,6 +689,12 @@ int sc_select_file(sc_card_t *card, const sc_path_t *in_path, sc_file_t **file)
|
||||||
if (r != SC_SUCCESS)
|
if (r != SC_SUCCESS)
|
||||||
pbuf[0] = '\0';
|
pbuf[0] = '\0';
|
||||||
|
|
||||||
|
/* FIXME We should be a bit less strict and let the upper layers do
|
||||||
|
* the initialization (including reuse of existing file objects). We
|
||||||
|
* implemented this here because we are lazy. */
|
||||||
|
if (file != NULL)
|
||||||
|
*file = NULL;
|
||||||
|
|
||||||
sc_log(card->ctx, "called; type=%d, path=%s", in_path->type, pbuf);
|
sc_log(card->ctx, "called; type=%d, path=%s", in_path->type, pbuf);
|
||||||
if (in_path->len > SC_MAX_PATH_SIZE)
|
if (in_path->len > SC_MAX_PATH_SIZE)
|
||||||
LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
|
LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
|
@ -713,9 +719,16 @@ int sc_select_file(sc_card_t *card, const sc_path_t *in_path, sc_file_t **file)
|
||||||
r = card->ops->select_file(card, in_path, file);
|
r = card->ops->select_file(card, in_path, file);
|
||||||
LOG_TEST_RET(card->ctx, r, "'SELECT' error");
|
LOG_TEST_RET(card->ctx, r, "'SELECT' error");
|
||||||
|
|
||||||
|
if (file) {
|
||||||
|
if (*file)
|
||||||
/* Remember file path */
|
/* Remember file path */
|
||||||
if (file && *file)
|
|
||||||
(*file)->path = *in_path;
|
(*file)->path = *in_path;
|
||||||
|
else
|
||||||
|
/* FIXME We should be a bit less strict and let the upper layers do
|
||||||
|
* the error checking. We implemented this here because we are
|
||||||
|
* lazy. */
|
||||||
|
r = SC_ERROR_INVALID_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
LOG_FUNC_RETURN(card->ctx, r);
|
LOG_FUNC_RETURN(card->ctx, r);
|
||||||
}
|
}
|
||||||
|
|
|
@ -457,9 +457,6 @@ iso7816_select_file(struct sc_card *card, const struct sc_path *in_path, struct
|
||||||
pathlen = in_path->len;
|
pathlen = in_path->len;
|
||||||
pathtype = in_path->type;
|
pathtype = in_path->type;
|
||||||
|
|
||||||
if (file_out != NULL) {
|
|
||||||
*file_out = NULL;
|
|
||||||
}
|
|
||||||
if (in_path->aid.len) {
|
if (in_path->aid.len) {
|
||||||
if (!pathlen) {
|
if (!pathlen) {
|
||||||
memcpy(path, in_path->aid.value, in_path->aid.len);
|
memcpy(path, in_path->aid.value, in_path->aid.len);
|
||||||
|
|
Loading…
Reference in New Issue