Blame SOURCES/opensc-0.20.0-CVE-2020-26571.patch

176fa0
commit ed55fcd2996930bf58b9bb57e9ba7b1f3a753c43
176fa0
Author: Frank Morgner <frankmorgner@gmail.com>
176fa0
Date:   Mon May 18 17:25:32 2020 +0200
176fa0
176fa0
    fixed invalid read
176fa0
    
176fa0
    fixes https://oss-fuzz.com/testcase-detail/5765246676631552
176fa0
176fa0
diff --git a/src/libopensc/pkcs15-gemsafeGPK.c b/src/libopensc/pkcs15-gemsafeGPK.c
176fa0
index e13f3b87..4b80daf2 100644
176fa0
--- a/src/libopensc/pkcs15-gemsafeGPK.c
176fa0
+++ b/src/libopensc/pkcs15-gemsafeGPK.c
176fa0
@@ -205,7 +205,7 @@ static int sc_pkcs15emu_gemsafeGPK_init(sc_pkcs15_card_t *p15card)
176fa0
 
176fa0
 	u8 sysrec[7];
176fa0
 	int num_keyinfo = 0;
176fa0
-	keyinfo kinfo[8]; /* will loook for 8 keys */
176fa0
+	keyinfo kinfo[9]; /* will look for 9 keys */
176fa0
 	u8 modulus_buf[ 1 + 1024 / 8]; /* tag+modulus */
176fa0
 	u8 *cp;
176fa0
 	char buf[256];
176fa0
@@ -255,9 +255,9 @@ static int sc_pkcs15emu_gemsafeGPK_init(sc_pkcs15_card_t *p15card)
176fa0
 
176fa0
 	/* There may be more then one key in the directory. */
176fa0
 	/* we need to find them so we can associate them with the */
176fa0
-	/* the certificate.  The files are 0007 to 000f */
176fa0
+	/* the certificate.  The files are 0007 to 000F */
176fa0
 
176fa0
-	for (i = 7; i < 16; i++) {
176fa0
+	for (i = 0x7; i <= 0xF; i++) {
176fa0
 		path.value[0] = 0x00;
176fa0
 		path.value[1] = i;
176fa0
 		path.len = 2;	
176fa0
@@ -297,7 +297,7 @@ static int sc_pkcs15emu_gemsafeGPK_init(sc_pkcs15_card_t *p15card)
176fa0
 		while (j--) 
176fa0
 			*cp++ =  modulus_buf[j + 1];
176fa0
 		num_keyinfo++;
176fa0
-	} 
176fa0
+	}
176fa0
 
176fa0
 	/* Get the gemsafe data with the cert */
176fa0
 	 sc_format_path("3F000200004", &path);