Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow reading data group from eMRTD with npa-tool #2257

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/libopensc/card.c
Expand Up @@ -652,14 +652,15 @@ int sc_read_binary(sc_card_t *card, unsigned int idx,
r = card->ops->read_binary(card, idx, buf, chunk, flags);
if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
break;
if (r < 0) {
sc_unlock(card);
LOG_FUNC_RETURN(card->ctx, r);
}
if ((idx > SIZE_MAX - (size_t) r)
|| (size_t) r > todo) {
/* `idx + r` or `todo - r` would overflow */
r = SC_ERROR_OFFSET_TOO_LARGE;
}
if (r < 0) {
sc_unlock(card);
LOG_FUNC_RETURN(card->ctx, r);
LOG_FUNC_RETURN(card->ctx, SC_ERROR_OFFSET_TOO_LARGE);
}

todo -= (size_t) r;
Expand Down
3 changes: 2 additions & 1 deletion src/libopensc/iso7816.c
Expand Up @@ -157,7 +157,8 @@ iso7816_read_binary(struct sc_card *card, unsigned int idx, u8 *buf, size_t coun
LOG_TEST_RET(ctx, r, "APDU transmit failed");

r = sc_check_sw(card, apdu.sw1, apdu.sw2);
if (r == SC_ERROR_FILE_END_REACHED)
if (r == SC_ERROR_FILE_END_REACHED
|| r == SC_ERROR_INCORRECT_PARAMETERS)
LOG_FUNC_RETURN(ctx, apdu.resplen);
LOG_TEST_RET(ctx, r, "Check SW error");

Expand Down