[prev in list] [next in list] [prev in thread] [next in thread]
List: openssl-users
Subject: Re: Cert memory leak ...
From: Goetz Babin-Ebell <goetz () shomitefo ! de>
Date: 2005-09-30 23:58:36
Message-ID: 433DD12C.30006 () shomitefo ! de
[Download RAW message or body]
David Brock wrote:
> I'm still trying to track down some memory leaks and using the following
> code I'm see leaks in the OpenSSL library. Could some one please let me
> know if I'm making these calls incorrectly, or if there are any patches
> (other then upgrading to 0.9.8) that can be applied to fix the leaks. We
> are currently using 0.9.7g.
> void
> process(EVP_PKEY **pubKey)
> {
> X509 *rootCert = NULL;
> FILE *fp;
> BIO *fileBio = NULL;
> fp =
> fopen("/home/dbrock/src/GMSModule/certs/production/cacert.pem","r");
> if (fp == NULL)
> {
> printf("Error could not open root cert\n");
> return -1;
> }
> fileBio = BIO_new(BIO_s_file());
> BIO_set_fp(fileBio,fp,BIO_NOCLOSE);
Why don't you simply do a
BIO *fileBio = BIO_new_file("/home/dbrock/src/GMSModule/certs/production/cacert.pem","r");
if (!fileBio)
...
> rootCert = PEM_read_bio_X509(fileBio,NULL, NULL, NULL);
> if (rootCert == NULL)
> {
> printf("Error could not open root cert\n");
> return -1;
> }
> /* Pull out the public key */
> if ((*pubKey = X509_get_pubkey(rootCert)) == NULL)
> {
> printf("Error could not get public key\n");
> return -1;
> }
> BIO_free(fileBio);
> fileBio = NULL;
> (void) fclose(fp);
> fp = NULL;
> OPENSSL_free(rootCert);
X509_free(rootcert);
> return 0;
> }
>
> int
> main (int argc, char **argv)
> {
> EVP_PKEY *pubKey = NULL;
> process(&pubKey);
> OPENSSL_free(pubKey);
EVP_PKEY_free(pubkey);
> return 0;
> }
Bye
Goetz
--
DMCA: The greed of the few outweighs the freedom of the many
["smime.p7s" (application/x-pkcs7-signature)]
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majordomo@openssl.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic