iso7816_*_sfid: return the number of bytes processed

This commit is contained in:
Frank Morgner 2020-01-31 15:04:08 +01:00
parent ad8b9f5034
commit 70baccbe95
4 changed files with 15 additions and 10 deletions

View File

@ -515,9 +515,8 @@ authentic_erase_binary(struct sc_card *card, unsigned int offs, size_t count, un
rv = sc_update_binary(card, offs, buf_zero, count, flags);
free(buf_zero);
LOG_TEST_RET(ctx, rv, "'ERASE BINARY' failed");
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
LOG_FUNC_RETURN(ctx, rv);
}

View File

@ -695,7 +695,7 @@ iasecc_erase_binary(struct sc_card *card, unsigned int offs, size_t count, unsig
rv = sc_update_binary(card, offs, tmp, count, flags);
free(tmp);
LOG_TEST_RET(ctx, rv, "iasecc_erase_binary() update binary error");
LOG_FUNC_RETURN(ctx, rv);
}

View File

@ -650,7 +650,7 @@ int sc_read_binary(sc_card_t *card, unsigned int idx,
size_t chunk = todo > max_le ? max_le : todo;
r = card->ops->read_binary(card, idx, buf, chunk, flags);
if (r == 0 || r = SC_ERROR_FILE_END_REACHED)
if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
break;
if ((idx > SIZE_MAX - (size_t) r)
|| (size_t) r > todo) {
@ -698,7 +698,7 @@ int sc_write_binary(sc_card_t *card, unsigned int idx,
size_t chunk = todo > max_lc ? max_lc : todo;
r = card->ops->write_binary(card, idx, buf, chunk, flags);
if (r == 0 || r = SC_ERROR_FILE_END_REACHED)
if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
break;
if ((idx > SIZE_MAX - (size_t) r)
|| (size_t) r > todo) {
@ -754,7 +754,7 @@ int sc_update_binary(sc_card_t *card, unsigned int idx,
size_t chunk = todo > max_lc ? max_lc : todo;
r = card->ops->update_binary(card, idx, buf, chunk, flags);
if (r == 0 || r = SC_ERROR_FILE_END_REACHED)
if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
break;
if ((idx > SIZE_MAX - (size_t) r)
|| (size_t) r > todo) {
@ -800,7 +800,7 @@ int sc_erase_binary(struct sc_card *card, unsigned int idx, size_t count, unsig
while (todo > 0) {
r = card->ops->erase_binary(card, idx, todo, flags);
if (r == 0 || r = SC_ERROR_FILE_END_REACHED)
if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
break;
if ((idx > SIZE_MAX - (size_t) r)
|| (size_t) r > todo) {

View File

@ -1322,6 +1322,8 @@ int iso7816_read_binary_sfid(sc_card_t *card, unsigned char sfid,
*ef_len += r;
break;
}
if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
break;
if (r < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Could not read EF.");
goto err;
@ -1339,7 +1341,7 @@ int iso7816_read_binary_sfid(sc_card_t *card, unsigned char sfid,
*ef + *ef_len, read, 0);
}
r = SC_SUCCESS;
r = *ef_len;
err:
return r;
@ -1399,6 +1401,8 @@ int iso7816_write_binary_sfid(sc_card_t *card, unsigned char sfid,
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Could not write EF.");
goto err;
}
if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
break;
wrote += r;
apdu.data += r;
if (wrote >= ef_len)
@ -1407,7 +1411,7 @@ int iso7816_write_binary_sfid(sc_card_t *card, unsigned char sfid,
r = sc_write_binary(card, wrote, ef, write, 0);
}
r = SC_SUCCESS;
r = wrote;
err:
return r;
@ -1467,6 +1471,8 @@ int iso7816_update_binary_sfid(sc_card_t *card, unsigned char sfid,
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Could not update EF.");
goto err;
}
if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
break;
wrote += r;
apdu.data += r;
if (wrote >= ef_len)
@ -1475,7 +1481,7 @@ int iso7816_update_binary_sfid(sc_card_t *card, unsigned char sfid,
r = sc_update_binary(card, wrote, ef, write, 0);
}
r = SC_SUCCESS;
r = wrote;
err:
return r;