libopensc: avoid the using of not completely initialized 'sc_path' variables

to be continued...


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5103 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
vtarasov 2011-01-17 19:00:52 +00:00
parent d1f7e7b8c8
commit 3efe35d246
9 changed files with 19 additions and 4 deletions

View File

@ -63,8 +63,9 @@ static int acos5_select_file_by_path(sc_card_t * card,
{
int in_len = in_path->len;
const u8 *in_pos = in_path->value;
sc_path_t path;
memset(&path, 0, sizeof(sc_path_t));
path.len = 2; /* one component at a time */
path.type = SC_PATH_TYPE_FILE_ID;

View File

@ -55,6 +55,8 @@ static int asepcos_select_asepcos_applet(sc_card_t *card)
sc_path_t tpath;
int r;
memset(&tpath, 0, sizeof(sc_path_t));
tpath.type = SC_PATH_TYPE_DF_NAME;
tpath.len = sizeof(asepcos_aid);
memcpy(tpath.value, asepcos_aid, sizeof(asepcos_aid));

View File

@ -474,7 +474,8 @@ static int atrust_acos_select_file(struct sc_card *card,
/* first step: change directory */
r = atrust_acos_select_fid(card, path[bMatch], path[bMatch+1], NULL);
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "SELECT FILE (DF-ID) failed");
memset(&new_path, 0, sizeof(sc_path_t));
new_path.type = SC_PATH_TYPE_PATH;
new_path.len = pathlen - bMatch-2;
memcpy(new_path.value, &(path[bMatch+2]), new_path.len);

View File

@ -455,6 +455,8 @@ static int entersafe_select_fid(sc_card_t *card,
sc_file_t *file=0;
sc_path_t path;
memset(&path, 0, sizeof(sc_path_t));
path.type=SC_PATH_TYPE_FILE_ID;
path.value[0]=id_hi;
path.value[1]=id_lo;
@ -584,7 +586,9 @@ static int entersafe_select_path(sc_card_t *card,
/* first step: change directory */
r = entersafe_select_fid(card, path[bMatch], path[bMatch+1], NULL);
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "SELECT FILE (DF-ID) failed");
memset(&new_path, 0, sizeof(sc_path_t));
new_path.type = SC_PATH_TYPE_PATH;
new_path.len = pathlen - bMatch-2;
memcpy(new_path.value, &(path[bMatch+2]), new_path.len);

View File

@ -64,6 +64,8 @@ static int ias_select_applet(sc_card_t *card, const u8 *aid, size_t aid_len)
int r;
sc_path_t tpath;
memset(&tpath, 0, sizeof(sc_path_t));
tpath.type = SC_PATH_TYPE_DF_NAME;
tpath.len = aid_len;
memcpy(tpath.value, aid, aid_len);

View File

@ -354,6 +354,8 @@ pgp_select_file(sc_card_t *card, const sc_path_t *path, sc_file_t **ret)
unsigned int n;
int r;
memset(&path_copy, 0, sizeof(path_copy));
if (path->type == SC_PATH_TYPE_DF_NAME)
return iso_ops->select_file(card, path, ret);
if (path->type != SC_PATH_TYPE_PATH)

View File

@ -456,7 +456,8 @@ static int starcos_select_file(sc_card_t *card,
/* first step: change directory */
r = starcos_select_fid(card, path[bMatch], path[bMatch+1], NULL);
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "SELECT FILE (DF-ID) failed");
memset(&new_path, 0, sizeof(sc_path_t));
new_path.type = SC_PATH_TYPE_PATH;
new_path.len = pathlen - bMatch-2;
memcpy(new_path.value, &(path[bMatch+2]), new_path.len);

View File

@ -445,6 +445,7 @@ static int enum_dir(sc_path_t path, int depth)
for (i = 0; i < r/2; i++) {
sc_path_t tmppath;
memset(&tmppath, 0, sizeof(tmppath));
memcpy(&tmppath, &path, sizeof(path));
memcpy(tmppath.value + tmppath.len, files + 2*i, 2);
tmppath.len += 2;

View File

@ -1382,6 +1382,7 @@ static int learn_card(void)
printf("[%s]\n", certs[i]->label);
memset(&tpath, 0, sizeof(tpath));
tpath = cinfo->path;
if (tpath.type == SC_PATH_TYPE_FILE_ID) {
/* prepend application DF path in case of a file id */