OpenPGP: update pgp_list_files()
* fail if buffer passed as parameter is too small * only list readable objects Signed-off-by: Peter Marschall <peter@adpm.de>
This commit is contained in:
parent
2e7406922f
commit
961a27c921
|
@ -727,8 +727,14 @@ pgp_list_files(sc_card_t *card, u8 *buf, size_t buflen)
|
|||
if ((r = pgp_enumerate_blob(card, blob)) < 0)
|
||||
LOG_FUNC_RETURN(card->ctx, r);
|
||||
|
||||
for (k = 0, blob = blob->files; (blob != NULL) && (k + 2 <= buflen); blob = blob->next, k += 2) {
|
||||
ushort2bebytes(buf + k, blob->id);
|
||||
for (k = 0, blob = blob->files; blob != NULL; blob = blob->next) {
|
||||
if (blob->info != NULL && (blob->info->access & READ_MASK) != READ_NEVER) {
|
||||
if (k + 2 > buflen)
|
||||
LOG_FUNC_RETURN(card->ctx, SC_ERROR_BUFFER_TOO_SMALL);
|
||||
|
||||
ushort2bebytes(buf + k, blob->id);
|
||||
k += 2;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_FUNC_RETURN(card->ctx, k);
|
||||
|
|
Loading…
Reference in New Issue