Richard Levitte - VMS Whacker wrote:

In message <[EMAIL PROTECTED]> on Fri, 02 Dec 2005 12:09:14 -0800, Matthew Rodriguez 
DSD staff <[EMAIL PROTECTED]> said:

MKRodriguez> I can't seem to get rid of a memory leak when I create a
MKRodriguez> proxyCertInfo extension. I've tried calling
MKRodriguez> X509_EXTENSION_free, and then X509_EXT_cleanup. I don't
MKRodriguez> think I need to do that because it is not a custom
MKRodriguez> extension, I'm using openssl-0.9.8a.

Have you tried PROXY_CERT_INFO_EXTENSION_free() ?

Cheers,
Richard

I get a segmentation fault when I try and do a PROXY_CERT_INFO_EXTENSION_free.
Here is the stack trace.

Program received signal SIGSEGV, Segmentation fault.
0x400de99e in ASN1_primitive_free (pval=0x103, it=0x40143b70) at tasn_fre.c:237
237                     if ((utype != V_ASN1_BOOLEAN) && !*pval)
(gdb) bt
#0  0x400de99e in ASN1_primitive_free (pval=0x103, it=0x40143b70)
   at tasn_fre.c:237
#1 0x400de5c7 in asn1_item_combine_free (pval=0x103, it=0x40143b70, combine=0)
   at tasn_fre.c:103
#2  0x400de8f2 in ASN1_template_free (pval=0x103, tt=0x401472b4)
   at tasn_fre.c:202
#3  0x400de7fb in asn1_item_combine_free (pval=0x8054d04, it=0x40144218,
   combine=0) at tasn_fre.c:172
#4  0x400de8f2 in ASN1_template_free (pval=0x8054d04, tt=0x401472f4)
   at tasn_fre.c:202
#5  0x400de7fb in asn1_item_combine_free (pval=0xbfffead0, it=0x40144234,
   combine=0) at tasn_fre.c:172
#6  0x400de4ef in ASN1_item_free (val=0x8054d00, it=0x40144234)
   at tasn_fre.c:71
#7 0x401048ca in PROXY_CERT_INFO_EXTENSION_free (a=0x8054d00) at v3_pcia.c:55
#8  0x080488a5 in main (argc=1, argv=0xbfffebb4) at x509_ext.c:25
(gdb) I'll have to step through these 2 cases more carefully. I see that X509_EXTENSION_free and PROXY_CERT_INFO_EXTENSION_free both go through the ASN1_item free, and ASN1_item_combine_free
but somewhere after that they go through different codepaths.

Matt
#include <openssl/x509v3.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
static char * pci_value = "critical, language:Inherit all";

int 
main(int argc, char **argv){
	X509_EXTENSION *ext =NULL;
	X509V3_CTX *ctx; 
	LHASH *lhash;
	SSL_library_init();
	OpenSSL_add_all_ciphers();
	OpenSSL_add_all_algorithms();
	SSL_load_error_strings();
	lhash = lh_new(NULL, NULL); 
    X509V3_set_conf_lhash(ctx, lhash); 
	ext = X509V3_EXT_conf(NULL, ctx, "proxyCertInfo", pci_value);
	if (ext == NULL){
        ERR_print_errors_fp(stderr);
		exit(-1);
	}
    X509V3_EXT_print_fp(stdout, ext, 0, 0);
    X509_EXTENSION_free(ext);
	/*X509V3_EXT_cleanup();
	PROXY_CERT_INFO_EXTENSION_free((PROXY_CERT_INFO_EXTENSION *)ext); */
	return 0;
}

Reply via email to