diff options
author | Heikki Toivonen <heikki@heikkitoivonen.net> | 2007-06-13 22:57:34 +0000 |
---|---|---|
committer | Heikki Toivonen <heikki@heikkitoivonen.net> | 2007-06-13 22:57:34 +0000 |
commit | d767fc46d32f8fac01ae73b37bde6f5fccb9b695 (patch) | |
tree | 40e1f8c992e5376453bd77db2069493de19d765b /tests/test_x509.py | |
parent | 6df482996cb3d1ac49df8d16ca06961b172316be (diff) | |
download | m2crypto-d767fc46d32f8fac01ae73b37bde6f5fccb9b695.tar.gz |
Fixed memory leak in X509_Stack (which manifested for example when calling new_stack_from_der).
git-svn-id: http://svn.osafoundation.org/m2crypto/trunk@550 2715db39-9adf-0310-9c64-84f055769b4b
Diffstat (limited to 'tests/test_x509.py')
-rw-r--r-- | tests/test_x509.py | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py index 3670376..b88a1e2 100644 --- a/tests/test_x509.py +++ b/tests/test_x509.py @@ -313,7 +313,7 @@ class X509TestCase(unittest.TestCase): proxycert.set_subject_name(subject_name) pci_ext = X509.new_extension("proxyCertInfo", - "critical,language:Inherit all", 1) # XXX leaks 8 bytes + "critical,language:Inherit all", 1) # XXX leaks 8 bytes proxycert.add_ext(pci_ext) return proxycert @@ -394,7 +394,7 @@ class X509TestCase(unittest.TestCase): class X509_StackTestCase(unittest.TestCase): - def test_make_stack_from_der(self): # XXX leaks 92/2518 bytes + def test_make_stack_from_der(self): f = open("tests/der_encoded_seq.b64") b64 = f.read(1304) seq = base64.decodestring(b64) @@ -403,8 +403,8 @@ class X509_StackTestCase(unittest.TestCase): subject = cert.get_subject() assert str(subject) == "/DC=org/DC=doegrids/OU=Services/CN=host/bosshog.lbl.gov" - - def test_make_stack_check_num(self): # XXX leaks 92/2518 bytes + + def test_make_stack_check_num(self): f = open("tests/der_encoded_seq.b64") b64 = f.read(1304) seq = base64.decodestring(b64) @@ -440,7 +440,7 @@ class X509_StackTestCase(unittest.TestCase): assert str(cert_subject1) == str(cert_subject2) assert str(issuer_subject1) == str(issuer_subject2) - def test_as_der(self): # XXX leaks 184/4199 bytes + def test_as_der(self): stack = X509.X509_Stack() cert = X509.load_cert("tests/x509.pem") issuer = X509.load_cert("tests/ca.pem") @@ -458,10 +458,27 @@ class X509_StackTestCase(unittest.TestCase): assert str(issuer_subject1) == str(issuer_subject2) +class X509_ExtTestCase(unittest.TestCase): + + def test_ext(self): + # With this leaks 8 bytes: + name = "proxyCertInfo" + value = "critical,language:Inherit all" + # With this there are no leaks: + #name = "nsComment" + #value = "Hello" + critical = 1 + + lhash = m2.x509v3_lhash() + ctx = m2.x509v3_set_conf_lhash(lhash) + x509_ext_ptr = m2.x509v3_ext_conf(lhash, ctx, name, value) + x509_ext = X509.X509_Extension(x509_ext_ptr, 1) + def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(X509TestCase)) suite.addTest(unittest.makeSuite(X509_StackTestCase)) + #suite.addTest(unittest.makeSuite(X509_ExtTestCase)) return suite |