free rsa structures when deleting a struct rmconf. patch by Roman Hoog Antink <rha@open.ch>

This commit is contained in:
vanhu 2011-03-02 15:04:01 +00:00
parent 78c9c4b8d1
commit 7e1e999bc0
3 changed files with 26 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: remoteconf.c,v 1.24 2011/03/02 14:58:27 vanhu Exp $ */
/* $NetBSD: remoteconf.c,v 1.25 2011/03/02 15:04:01 vanhu Exp $ */
/* Id: remoteconf.c,v 1.38 2006/05/06 15:52:44 manubsd Exp */
@ -78,6 +78,7 @@
#include "isakmp_frag.h"
#include "handler.h"
#include "genlist.h"
#include "rsalist.h"
typedef TAILQ_HEAD(_rmtree, remoteconf) remoteconf_tailq_head_t;
static remoteconf_tailq_head_t rmtree, rmtree_save;
@ -650,6 +651,10 @@ delrmconf(rmconf)
vfree(rmconf->cacert);
if (rmconf->cacertfile)
racoon_free(rmconf->cacertfile);
if (rmconf->rsa_private)
genlist_free(rmconf->rsa_private, rsa_key_free);
if (rmconf->rsa_public)
genlist_free(rmconf->rsa_public, rsa_key_free);
if (rmconf->name)
racoon_free(rmconf->name);
if (rmconf->remote)

View File

@ -1,4 +1,4 @@
/* $NetBSD: rsalist.c,v 1.4 2006/09/09 16:22:10 manu Exp $ */
/* $NetBSD: rsalist.c,v 1.5 2011/03/02 15:04:01 vanhu Exp $ */
/* Id: rsalist.c,v 1.3 2004/11/08 12:04:23 ludvigm Exp */
@ -88,6 +88,23 @@ rsa_key_insert(struct genlist *list, struct netaddr *src,
return 0;
}
void
rsa_key_free(void *data)
{
struct rsa_key *rsa_key;
rsa_key = (struct rsa_key *)data;
if (rsa_key->src)
free(rsa_key->src);
if (rsa_key->dst)
free(rsa_key->dst);
if (rsa_key->rsa)
RSA_free(rsa_key->rsa);
free(rsa_key);
}
static void *
rsa_key_dump_one(void *entry, void *arg)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: rsalist.h,v 1.4 2006/09/09 16:22:10 manu Exp $ */
/* $NetBSD: rsalist.h,v 1.5 2011/03/02 15:04:01 vanhu Exp $ */
/* Id: rsalist.h,v 1.2 2004/07/12 20:43:51 ludvigm Exp */
/*
@ -53,6 +53,7 @@ struct rsa_key {
};
int rsa_key_insert(struct genlist *list, struct netaddr *src, struct netaddr *dst, RSA *rsa);
void rsa_key_free(void *data);
void rsa_key_dump(struct genlist *list);
struct genlist *rsa_lookup_keys(struct ph1handle *iph1, int my);