RSA keys must be freed by using openssl's RSA_free() rather than the
usual free(). This leak turns out to be more serious as the amount
of leaked memory increased by about 300 bytes every time para_server
reread the user list (i.e. the hup command was executed or para_server
received SIGHUP).
return RSA_size(*rsa);
}
+/**
+ * free an RSA structure
+ *
+ * \param rsa pointer to the RSA struct to free
+ *
+ * This must be called for any key obtained by get_rsa_key().
+ */
+void rsa_free(RSA *rsa)
+{
+ if (rsa)
+ RSA_free(rsa);
+}
+
/**
* decrypt a buffer using an RSA key
*
/*
- * Copyright (C) 2005-2006 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005-2007 Andre Noll <maan@systemlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
int rsa_inlen);
int get_rsa_key(char *key_file, RSA **rsa, int private);
+void rsa_free(RSA *rsa);
+
/** \cond used to distinguish between loading of private/public key */
#define LOAD_PUBLIC_KEY 0
#define LOAD_PRIVATE_KEY 1
list_for_each_entry_safe(u, tmp, &user_list, node) {
list_del(&u->node);
free(u->name);
- free(u->rsa);
+ rsa_free(u->rsa);
free(u);
}
} else