Skip to content

Commit 5d4daf6

Browse files
committed
oberthur: One more overlooked buffer overflow
Thanks oss-fuzz https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32202
1 parent 715c17c commit 5d4daf6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libopensc/pkcs15-oberthur.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,10 @@ sc_pkcs15emu_oberthur_add_pubkey(struct sc_pkcs15_card *p15card,
609609
LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Failed to add public key: no 'Label'");
610610
}
611611
len = *(info_blob + offs + 1) + *(info_blob + offs) * 0x100;
612-
if (len) {
612+
if (offs + 2 + len > info_len) {
613+
free(info_blob);
614+
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Failed to add public key: invalid 'Label' length");
615+
} else if (len) {
613616
if (len > sizeof(key_obj.label) - 1)
614617
len = sizeof(key_obj.label) - 1;
615618
memcpy(key_obj.label, info_blob + offs + 2, len);

0 commit comments

Comments
 (0)