Skip to content

Commit

Permalink
Fix error check in pgp_enumerate_blob
Browse files Browse the repository at this point in the history
  • Loading branch information
ya-isakov authored and Jakuje committed Dec 4, 2021
1 parent 21347de commit d4b5890
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/libopensc/card-openpgp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1246,14 +1246,16 @@ pgp_enumerate_blob(sc_card_t *card, pgp_blob_t *blob)

r = sc_asn1_read_tag(&data, blob->len - (in - blob->data),
&cla, &tag, &len);
if (data == NULL) {
sc_log(card->ctx, "Unexpected end of contents");
return SC_ERROR_OBJECT_NOT_VALID;
}
if (r == SC_ERROR_INVALID_ASN1_OBJECT) {
sc_log(card->ctx, "Invalid ASN.1 object");
return SC_ERROR_OBJECT_NOT_VALID;
}
/* Check for unknown error, or empty data */
if (((r < 0) && (r != SC_ERROR_ASN1_END_OF_CONTENTS)) ||
(data == NULL)) {
sc_log(card->ctx, "Unexpected end of contents");
return SC_ERROR_OBJECT_NOT_VALID;
}

/* undo ASN1's split of tag & class */
for (tmptag = tag; tmptag > 0x0FF; tmptag >>= 8) {
Expand Down

0 comments on commit d4b5890

Please sign in to comment.