Skip to content

Commit 05648b0

Browse files
frankmorgnerJakuje
authored andcommitted
oberthur: fixed Heap-buffer-overflow
fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32149
1 parent fc0df4e commit 05648b0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: src/libopensc/pkcs15-oberthur.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -616,12 +616,14 @@ sc_pkcs15emu_oberthur_add_pubkey(struct sc_pkcs15_card *p15card,
616616
offs += 2 + len;
617617

618618
/* ID */
619-
if (offs > info_len) {
619+
if (offs + 2 > info_len) {
620620
free(info_blob);
621621
LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Failed to add public key: no 'ID'");
622622
}
623623
len = *(info_blob + offs + 1) + *(info_blob + offs) * 0x100;
624-
if (!len || len > sizeof(key_info.id.value)) {
624+
if (len == 0
625+
|| len > sizeof(key_info.id.value)
626+
|| offs + 2 + len > info_len) {
625627
free(info_blob);
626628
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Failed to add public key: invalid 'ID' length");
627629
}

0 commit comments

Comments
 (0)