Skip to content

Commit

Permalink
oberthur: fixed Heap-buffer-overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
frankmorgner authored and Jakuje committed Mar 18, 2021
1 parent fc0df4e commit 05648b0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/libopensc/pkcs15-oberthur.c
Expand Up @@ -616,12 +616,14 @@ sc_pkcs15emu_oberthur_add_pubkey(struct sc_pkcs15_card *p15card,
offs += 2 + len;

/* ID */
if (offs > info_len) {
if (offs + 2 > info_len) {
free(info_blob);
LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Failed to add public key: no 'ID'");
}
len = *(info_blob + offs + 1) + *(info_blob + offs) * 0x100;
if (!len || len > sizeof(key_info.id.value)) {
if (len == 0
|| len > sizeof(key_info.id.value)
|| offs + 2 + len > info_len) {
free(info_blob);
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Failed to add public key: invalid 'ID' length");
}
Expand Down

0 comments on commit 05648b0

Please sign in to comment.