summaryrefslogtreecommitdiff
path: root/leakcheck
diff options
context:
space:
mode:
authorJonathan Giannuzzi <jonathan@giannuzzi.be>2014-03-24 01:33:08 +0100
committerJonathan Giannuzzi <jonathan@giannuzzi.be>2014-03-30 21:58:08 +0200
commit54c42008e8c0b993388c0b6926f5d3c0a75ef9b0 (patch)
treebc43a99c3157662d34985a675a9e3afdf894261f /leakcheck
parent8e6a64ee4c4373235f52e78bfa56692cf22bbec7 (diff)
downloadpyopenssl-54c42008e8c0b993388c0b6926f5d3c0a75ef9b0.tar.gz
Add a leakcheck test for _X509_REVOKED_dup
Diffstat (limited to 'leakcheck')
-rw-r--r--leakcheck/crypto.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/leakcheck/crypto.py b/leakcheck/crypto.py
index c52b975..f5fe2f8 100644
--- a/leakcheck/crypto.py
+++ b/leakcheck/crypto.py
@@ -4,7 +4,10 @@
import sys
from OpenSSL.crypto import (
- FILETYPE_PEM, TYPE_DSA, Error, PKey, X509, load_privatekey, CRL, Revoked)
+ FILETYPE_PEM, TYPE_DSA, Error, PKey, X509, load_privatekey, CRL, Revoked,
+ _X509_REVOKED_dup)
+
+from OpenSSL._util import lib as _lib
@@ -127,6 +130,21 @@ class Checker_CRL(BaseChecker):
+class Checker_X509_REVOKED_dup(BaseChecker):
+ """
+ Leak checks for :py:obj:`_X509_REVOKED_dup`.
+ """
+ def check_X509_REVOKED_dup(self):
+ """
+ Copy an empty Revoked object repeatedly. The copy is not garbage
+ collected, therefore it needs to be manually freed.
+ """
+ for i in xrange(self.iterations * 100):
+ revoked_copy = _X509_REVOKED_dup(Revoked()._revoked)
+ _lib.X509_REVOKED_free(revoked_copy)
+
+
+
def vmsize():
return [x for x in file('/proc/self/status').readlines() if 'VmSize' in x]