Make ef_dir variable local

Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18821
This commit is contained in:
Jakub Jelen 2019-11-13 15:01:31 +01:00 committed by Frank Morgner
parent f11c286bc6
commit 75847f4e93
3 changed files with 7 additions and 11 deletions

View File

@ -157,8 +157,6 @@ static void sc_card_free(sc_card_t *card)
sc_free_apps(card);
sc_free_ef_atr(card);
sc_file_free(card->ef_dir);
free(card->ops);
if (card->algorithms != NULL) {

View File

@ -160,6 +160,7 @@ int sc_enum_apps(sc_card_t *card)
int ef_structure;
size_t file_size, jj;
int r, ii, idx;
struct sc_file *ef_dir = NULL;
LOG_FUNC_CALLED(ctx);
@ -167,23 +168,21 @@ int sc_enum_apps(sc_card_t *card)
card->app_count = 0;
sc_format_path("3F002F00", &path);
sc_file_free(card->ef_dir);
card->ef_dir = NULL;
r = sc_select_file(card, &path, &card->ef_dir);
r = sc_select_file(card, &path, &ef_dir);
LOG_TEST_RET(ctx, r, "Cannot select EF.DIR file");
if (card->ef_dir->type != SC_FILE_TYPE_WORKING_EF) {
sc_file_free(card->ef_dir);
card->ef_dir = NULL;
if (ef_dir->type != SC_FILE_TYPE_WORKING_EF) {
sc_file_free(ef_dir);
LOG_TEST_RET(ctx, SC_ERROR_INVALID_CARD, "EF(DIR) is not a working EF.");
}
ef_structure = card->ef_dir->ef_structure;
ef_structure = ef_dir->ef_structure;
file_size = ef_dir->size;
sc_file_free(ef_dir);
if (ef_structure == SC_FILE_EF_TRANSPARENT) {
u8 *buf = NULL, *p;
size_t bufsize;
file_size = card->ef_dir->size;
if (file_size == 0)
LOG_FUNC_RETURN(ctx, 0);
if (file_size > MAX_FILE_SIZE)

View File

@ -580,7 +580,6 @@ typedef struct sc_card {
struct sc_app_info *app[SC_MAX_CARD_APPS];
int app_count;
struct sc_file *ef_dir;
struct sc_ef_atr *ef_atr;