diff options
author | Hakan Olsson <ho@cvs.openbsd.org> | 2001-04-12 15:50:03 +0000 |
---|---|---|
committer | Hakan Olsson <ho@cvs.openbsd.org> | 2001-04-12 15:50:03 +0000 |
commit | 41423283a1c67237868694dc0042ee47d8243b19 (patch) | |
tree | efeefd45a651924ab0036e77f97ccc2d38b8b602 /sbin | |
parent | eb7335549da238e10d2a1f974e1bd4c7ff891efd (diff) |
Correct various faulty x509 deallocations. By Niklas and me.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/isakmpd/x509.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/sbin/isakmpd/x509.c b/sbin/isakmpd/x509.c index 1496c5ba420..b3708e1f95a 100644 --- a/sbin/isakmpd/x509.c +++ b/sbin/isakmpd/x509.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509.c,v 1.48 2001/04/09 22:09:53 ho Exp $ */ +/* $OpenBSD: x509.c,v 1.49 2001/04/12 15:50:02 ho Exp $ */ /* $EOM: x509.c,v 1.54 2001/01/16 18:42:16 ho Exp $ */ /* @@ -598,10 +598,9 @@ x509_hash_init () { for (i = 0; i <= bucket_mask; i++) for (certh = LIST_FIRST (&x509_tab[i]); certh; - certh = LIST_NEXT (certh, link)) + certh = LIST_FIRST (&x509_tab[i])) { LIST_REMOVE (certh, link); - LC (X509_free, (certh->cert)); free (certh); } @@ -970,9 +969,27 @@ x509_cert_insert (int id, void *scert) return res; } +static struct x509_hash * +x509_hash_lookup (X509 *cert) +{ + int i; + struct x509_hash *certh; + + for (i = 0; i <= bucket_mask; i++) + for (certh = LIST_FIRST (&x509_tab[i]); certh; + certh = LIST_NEXT (certh, link)) + if (certh->cert == cert) + return certh; + return 0; +} + void x509_cert_free (void *cert) { + struct x509_hash *certh = x509_hash_lookup ((X509 *)cert); + + if (certh) + LIST_REMOVE (certh, link); LC (X509_free, ((X509 *)cert)); } |