From: Victor Wagner Date: Mon, 20 Jun 2016 14:01:30 +0000 (+0300) Subject: Check for CMS parsing error and don't pass None to CMS_get0_type. Fixes #3 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=13e7cc155149cf6e7c3789955e2d48be0a42cc26;p=oss%2Fctypescrypto.git Check for CMS parsing error and don't pass None to CMS_get0_type. Fixes #3 --- diff --git a/ctypescrypto/cms.py b/ctypescrypto/cms.py index 1e53387..685d52b 100644 --- a/ctypescrypto/cms.py +++ b/ctypescrypto/cms.py @@ -59,6 +59,8 @@ def CMS(data, format="PEM"): ptr = libcrypto.PEM_read_bio_CMS(bio.bio, None, None, None) else: ptr = libcrypto.d2i_CMS_bio(bio.bio, None) + if ptr is None: + raise CMSError("Error parsing CMS data") typeoid = Oid(libcrypto.OBJ_obj2nid(libcrypto.CMS_get0_type(ptr))) if typeoid.shortname() == "pkcs7-signedData": return SignedData(ptr)