From 2fae230794d5ab22b48ccc2b69a51c42845f6125 Mon Sep 17 00:00:00 2001 From: sth Date: Tue, 13 May 2003 07:06:29 +0000 Subject: [PATCH] Make sc_pkcs15_read_file() work if the pkcs15 files contain only FIDs instead of file paths (Nils Larsch) git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1099 c6295689-39f2-0310-b995-f0e70906c6a9 --- src/libopensc/pkcs15.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/libopensc/pkcs15.c b/src/libopensc/pkcs15.c index 6def8089..e6d237c9 100644 --- a/src/libopensc/pkcs15.c +++ b/src/libopensc/pkcs15.c @@ -1068,18 +1068,30 @@ ret: } int sc_pkcs15_read_file(struct sc_pkcs15_card *p15card, - const struct sc_path *path, + const struct sc_path *in_path, u8 **buf, size_t *buflen, struct sc_file **file_out) { - struct sc_file *file; + struct sc_file *file = NULL; + struct sc_path tmp_path, *path = &tmp_path; u8 *data = NULL; size_t len = 0, offset = 0; int r = -1; - assert(p15card != NULL && path != NULL && buf != NULL); + assert(p15card != NULL && in_path != NULL && buf != NULL); SC_FUNC_CALLED(p15card->card->ctx, 1); + if (in_path->type == SC_PATH_TYPE_FILE_ID) + { + /* in case of a FID prepend the application DF */ + memcpy(path, &p15card->file_app->path, sizeof(struct sc_path)); + sc_append_path(path, in_path); + path->index = in_path->index; + path->count = in_path->count; + } + else + memcpy(path, in_path, sizeof(struct sc_path)); + if (p15card->opts.use_cache) { r = sc_pkcs15_read_cached_file(p15card, path, &data, &len); }