]> wagner.pp.ru Git - oss/ctypescrypto.git/commitdiff
Check for CMS parsing error and don't pass None to CMS_get0_type. Fixes #3
authorVictor Wagner <vitus@wagner.pp.ru>
Mon, 20 Jun 2016 14:01:30 +0000 (17:01 +0300)
committerVictor Wagner <vitus@wagner.pp.ru>
Mon, 20 Jun 2016 14:01:30 +0000 (17:01 +0300)
ctypescrypto/cms.py

index 1e533875ded29e44f0604b7b95fffc8dca7a6f87..685d52bd642c1cde132c002f5c1f65b5d87eac2b 100644 (file)
@@ -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)