added error checking

This commit is contained in:
Frank Morgner 2015-10-14 23:10:48 +02:00
parent c371c3b5ec
commit e634169a92
1 changed files with 16 additions and 14 deletions

View File

@ -500,6 +500,8 @@ auth_select_file(struct sc_card *card, const struct sc_path *in_path,
rv = iso_ops->select_file(card, &path, &tmp_file);
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "select file failed");
if (!tmp_file)
return SC_ERROR_OBJECT_NOT_FOUND;
if (path.type == SC_PATH_TYPE_PARENT) {
memcpy(&tmp_file->path, &auth_current_df->path, sizeof(struct sc_path));
@ -1804,7 +1806,7 @@ auth_pin_reset_oberthur_style(struct sc_card *card, unsigned int type,
rv = iso_ops->select_file(card, &tmp_path, &tmp_file);
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "select PUK file");
if (tmp_file->size < OBERTHUR_AUTH_MAX_LENGTH_PUK)
if (!tmp_file || tmp_file->size < OBERTHUR_AUTH_MAX_LENGTH_PUK)
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_FILE_TOO_SMALL, "Oberthur style 'PIN RESET' failed");
rv = iso_ops->read_binary(card, 0, puk, OBERTHUR_AUTH_MAX_LENGTH_PUK, 0);