bpo-35746: Fix segfault in ssl's cert parser (GH-11569) (#11867) · python/cpython@efec763

Original file line numberDiff line numberDiff line change

@@ -69,6 +69,7 @@ def data_file(*name):

6969

BADKEY = data_file("badkey.pem")

7070

NOKIACERT = data_file("nokia.pem")

7171

NULLBYTECERT = data_file("nullbytecert.pem")

72+

TALOS_INVALID_CRLDP = data_file("talos-2019-0758.pem")

7273
7374

DHFILE = data_file("dh1024.pem")

7475

BYTES_DHFILE = os.fsencode(DHFILE)

@@ -252,6 +253,27 @@ def test_parse_cert(self):

252253

self.assertEqual(p['crlDistributionPoints'],

253254

('http://SVRIntl-G3-crl.verisign.com/SVRIntlG3.crl',))

254255
256+

def test_parse_cert_CVE_2019_5010(self):

257+

p = ssl._ssl._test_decode_cert(TALOS_INVALID_CRLDP)

258+

if support.verbose:

259+

sys.stdout.write("\n" + pprint.pformat(p) + "\n")

260+

self.assertEqual(

261+

p,

262+

{

263+

'issuer': (

264+

(('countryName', 'UK'),), (('commonName', 'cody-ca'),)),

265+

'notAfter': 'Jun 14 18:00:58 2028 GMT',

266+

'notBefore': 'Jun 18 18:00:58 2018 GMT',

267+

'serialNumber': '02',

268+

'subject': ((('countryName', 'UK'),),

269+

(('commonName',

270+

'codenomicon-vm-2.test.lal.cisco.com'),)),

271+

'subjectAltName': (

272+

('DNS', 'codenomicon-vm-2.test.lal.cisco.com'),),

273+

'version': 3

274+

}

275+

)

276+
255277

def test_parse_cert_CVE_2013_4238(self):

256278

p = ssl._ssl._test_decode_cert(NULLBYTECERT)

257279

if support.verbose: