35 lines
1.2 KiB
Diff
35 lines
1.2 KiB
Diff
From 05648b0604bf3e498e8d42dff3c6e7c56a5bf749 Mon Sep 17 00:00:00 2001
|
|
From: Frank Morgner <frankmorgner@gmail.com>
|
|
Date: Wed, 17 Mar 2021 18:16:34 +0100
|
|
Subject: [PATCH] oberthur: fixed Heap-buffer-overflow
|
|
|
|
fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32149
|
|
---
|
|
src/libopensc/pkcs15-oberthur.c | 6 ++++--
|
|
1 file changed, 4 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/libopensc/pkcs15-oberthur.c b/src/libopensc/pkcs15-oberthur.c
|
|
index ebaca47..314a7bd 100644
|
|
--- a/src/libopensc/pkcs15-oberthur.c
|
|
+++ b/src/libopensc/pkcs15-oberthur.c
|
|
@@ -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");
|
|
}
|
|
--
|
|
1.8.3.1
|
|
|