ssl/ssl_cert.c:762: error: RESOURCE_LEAK
  resource acquired by call to `opendir()` at line 737, column 6 is not released after line 762, column 7.
Showing all 85 steps of the trace


ssl/ssl_cert.c:729:1: start of procedure SSL_add_dir_cert_subjects_to_stack()
727.   #ifndef MAC_OS_pre_X
728.   
729. > int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
730.   				       const char *dir)
731.   	{

ssl/ssl_cert.c:734:2: 
732.   	DIR *d;
733.   	struct dirent *dstruct;
734. > 	int ret = 0;
735.   
736.   	CRYPTO_w_lock(CRYPTO_LOCK_READDIR);

ssl/ssl_cert.c:736:2: 
734.   	int ret = 0;
735.   
736. > 	CRYPTO_w_lock(CRYPTO_LOCK_READDIR);
737.   	d = opendir(dir);
738.   

crypto/cryptlib.c:375:1: start of procedure CRYPTO_lock()
  373.   	}
  374.   
  375. > void CRYPTO_lock(int mode, int type, const char *file, int line)
  376.   	{
  377.   #ifdef LOCK_DEBUG

crypto/cryptlib.c:400:6: Taking false branch
  398.   		}
  399.   #endif
  400.   	if (type < 0)
              ^
  401.   		{
  402.   		struct CRYPTO_dynlock_value *pointer

crypto/cryptlib.c:413:7: Taking true branch
  411.   		}
  412.   	else
  413.   		if (locking_callback != NULL)
               ^
  414.   			locking_callback(mode,type,file,line);
  415.   	}

crypto/cryptlib.c:414:4: Skipping __function_pointer__(): unresolved function pointer
  412.   	else
  413.   		if (locking_callback != NULL)
  414.   			locking_callback(mode,type,file,line);
            ^
  415.   	}
  416.   

crypto/cryptlib.c:400:2: 
  398.   		}
  399.   #endif
  400. > 	if (type < 0)
  401.   		{
  402.   		struct CRYPTO_dynlock_value *pointer

crypto/cryptlib.c:415:2: return from a call to CRYPTO_lock
  413.   		if (locking_callback != NULL)
  414.   			locking_callback(mode,type,file,line);
  415.   	}
          ^
  416.   
  417.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

ssl/ssl_cert.c:737:2: 
735.   
736.   	CRYPTO_w_lock(CRYPTO_LOCK_READDIR);
737. > 	d = opendir(dir);
738.   
739.   	/* Note that a side effect is that the CAs will be sorted by name */

ssl/ssl_cert.c:740:6: Taking false branch
738.   
739.   	/* Note that a side effect is that the CAs will be sorted by name */
740.   	if(!d)
            ^
741.   		{
742.   		SYSerr(SYS_F_OPENDIR, get_last_sys_error());

ssl/ssl_cert.c:748:9: Loop condition is true. Entering loop body
746.   		}
747.   	
748.   	while((dstruct=readdir(d)))
               ^
749.   		{
750.   		char buf[1024];

ssl/ssl_cert.c:753:6: Taking false branch
751.   		int r;
752.   		
753.   		if(strlen(dir)+strlen(dstruct->d_name)+2 > sizeof buf)
            ^
754.   			{
755.   			SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,SSL_R_PATH_TOO_LONG);

ssl/ssl_cert.c:759:3: Skipping BIO_snprintf(): empty list of specs
757.   			}
758.   		
759.   		r = BIO_snprintf(buf,sizeof buf,"%s/%s",dir,dstruct->d_name);
         ^
760.   		if (r <= 0 || r >= sizeof buf)
761.   			goto err;

ssl/ssl_cert.c:760:7: Taking false branch
758.   		
759.   		r = BIO_snprintf(buf,sizeof buf,"%s/%s",dir,dstruct->d_name);
760.   		if (r <= 0 || r >= sizeof buf)
             ^
761.   			goto err;
762.   		if(!SSL_add_file_cert_subjects_to_stack(stack,buf))

ssl/ssl_cert.c:760:17: Taking false branch
758.   		
759.   		r = BIO_snprintf(buf,sizeof buf,"%s/%s",dir,dstruct->d_name);
760.   		if (r <= 0 || r >= sizeof buf)
                       ^
761.   			goto err;
762.   		if(!SSL_add_file_cert_subjects_to_stack(stack,buf))

ssl/ssl_cert.c:762:7: 
760.   		if (r <= 0 || r >= sizeof buf)
761.   			goto err;
762. > 		if(!SSL_add_file_cert_subjects_to_stack(stack,buf))
763.   			goto err;
764.   		}

ssl/ssl_cert.c:664:1: start of procedure SSL_add_file_cert_subjects_to_stack()
  662.    */
  663.   
  664. > int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
  665.   					const char *file)
  666.   	{

ssl/ssl_cert.c:668:2: 
  666.   	{
  667.   	BIO *in;
  668. > 	X509 *x=NULL;
  669.   	X509_NAME *xn=NULL;
  670.   	int ret=1;

ssl/ssl_cert.c:669:2: 
  667.   	BIO *in;
  668.   	X509 *x=NULL;
  669. > 	X509_NAME *xn=NULL;
  670.   	int ret=1;
  671.   	int (*oldcmp)(const X509_NAME * const *a, const X509_NAME * const *b);

ssl/ssl_cert.c:670:2: 
  668.   	X509 *x=NULL;
  669.   	X509_NAME *xn=NULL;
  670. > 	int ret=1;
  671.   	int (*oldcmp)(const X509_NAME * const *a, const X509_NAME * const *b);
  672.   	

ssl/ssl_cert.c:673:2: 
  671.   	int (*oldcmp)(const X509_NAME * const *a, const X509_NAME * const *b);
  672.   	
  673. > 	oldcmp=sk_X509_NAME_set_cmp_func(stack,xname_cmp);
  674.   	
  675.   	in=BIO_new(BIO_s_file_internal());

crypto/stack/stack.c:79:1: start of procedure sk_set_cmp_func()
    77.   #include <errno.h>
    78.   
    79. > int (*sk_set_cmp_func(STACK *sk, int (*c)(const char * const *,const char * const *)))
    80.   		(const char * const *, const char * const *)
    81.   	{

crypto/stack/stack.c:82:2: 
    80.   		(const char * const *, const char * const *)
    81.   	{
    82. > 	int (*old)(const char * const *,const char * const *)=sk->comp;
    83.   
    84.   	if (sk->comp != c)

crypto/stack/stack.c:84:6: Taking true branch
    82.   	int (*old)(const char * const *,const char * const *)=sk->comp;
    83.   
    84.   	if (sk->comp != c)
               ^
    85.   		sk->sorted=0;
    86.   	sk->comp=c;

crypto/stack/stack.c:85:3: 
    83.   
    84.   	if (sk->comp != c)
    85. > 		sk->sorted=0;
    86.   	sk->comp=c;
    87.   

crypto/stack/stack.c:86:2: 
    84.   	if (sk->comp != c)
    85.   		sk->sorted=0;
    86. > 	sk->comp=c;
    87.   
    88.   	return old;

crypto/stack/stack.c:88:2: 
    86.   	sk->comp=c;
    87.   
    88. > 	return old;
    89.   	}
    90.   

crypto/stack/stack.c:89:2: return from a call to sk_set_cmp_func
    87.   
    88.   	return old;
    89.   	}
           ^
    90.   
    91.   STACK *sk_dup(STACK *sk)

ssl/ssl_cert.c:675:2: 
  673.   	oldcmp=sk_X509_NAME_set_cmp_func(stack,xname_cmp);
  674.   	
  675. > 	in=BIO_new(BIO_s_file_internal());
  676.   	
  677.   	if (in == NULL)

crypto/bio/bss_file.c:127:1: start of procedure BIO_s_file()
    125.   	}
    126.   
    127. > BIO_METHOD *BIO_s_file(void)
    128.   	{
    129.   	return(&methods_filep);

crypto/bio/bss_file.c:129:2: 
    127.   BIO_METHOD *BIO_s_file(void)
    128.   	{
    129. > 	return(&methods_filep);
    130.   	}
    131.   

crypto/bio/bss_file.c:130:2: return from a call to BIO_s_file
    128.   	{
    129.   	return(&methods_filep);
    130.   	}
            ^
    131.   
    132.   static int MS_CALLBACK file_new(BIO *bi)

crypto/bio/bio_lib.c:66:1: start of procedure BIO_new()
    64.   #include <openssl/stack.h>
    65.   
    66. > BIO *BIO_new(BIO_METHOD *method)
    67.   	{
    68.   	BIO *ret=NULL;

crypto/bio/bio_lib.c:68:2: 
    66.   BIO *BIO_new(BIO_METHOD *method)
    67.   	{
    68. > 	BIO *ret=NULL;
    69.   
    70.   	ret=(BIO *)OPENSSL_malloc(sizeof(BIO));

crypto/bio/bio_lib.c:70:2: 
    68.   	BIO *ret=NULL;
    69.   
    70. > 	ret=(BIO *)OPENSSL_malloc(sizeof(BIO));
    71.   	if (ret == NULL)
    72.   		{

crypto/mem.c:282:1: start of procedure CRYPTO_malloc()
      280.   	}
      281.   
      282. > void *CRYPTO_malloc(int num, const char *file, int line)
      283.   	{
      284.   	void *ret = NULL;

crypto/mem.c:284:2: 
      282.   void *CRYPTO_malloc(int num, const char *file, int line)
      283.   	{
      284. > 	void *ret = NULL;
      285.   
      286.   	allow_customize = 0;

crypto/mem.c:286:2: 
      284.   	void *ret = NULL;
      285.   
      286. > 	allow_customize = 0;
      287.   	if (malloc_debug_func != NULL)
      288.   		{

crypto/mem.c:287:6: Taking false branch
      285.   
      286.   	allow_customize = 0;
      287.   	if (malloc_debug_func != NULL)
                  ^
      288.   		{
      289.   		allow_customize_debug = 0;

crypto/mem.c:292:2: Skipping __function_pointer__(): unresolved function pointer
      290.   		malloc_debug_func(NULL, num, file, line, 0);
      291.   		}
      292.   	ret = malloc_ex_func(num,file,line);
              ^
      293.   #ifdef LEVITTE_DEBUG_MEM
      294.   	fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);

crypto/mem.c:296:6: Taking false branch
      294.   	fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);
      295.   #endif
      296.   	if (malloc_debug_func != NULL)
                  ^
      297.   		malloc_debug_func(ret, num, file, line, 1);
      298.   

crypto/mem.c:299:2: 
      297.   		malloc_debug_func(ret, num, file, line, 1);
      298.   
      299. > 	return ret;
      300.   	}
      301.   

crypto/mem.c:300:2: return from a call to CRYPTO_malloc
      298.   
      299.   	return ret;
      300.   	}
              ^
      301.   
      302.   void *CRYPTO_realloc(void *str, int num, const char *file, int line)

crypto/bio/bio_lib.c:71:6: Taking true branch
    69.   
    70.   	ret=(BIO *)OPENSSL_malloc(sizeof(BIO));
    71.   	if (ret == NULL)
               ^
    72.   		{
    73.   		BIOerr(BIO_F_BIO_NEW,ERR_R_MALLOC_FAILURE);

crypto/bio/bio_lib.c:73:3: 
    71.   	if (ret == NULL)
    72.   		{
    73. > 		BIOerr(BIO_F_BIO_NEW,ERR_R_MALLOC_FAILURE);
    74.   		return(NULL);
    75.   		}

crypto/err/err.c:582:1: start of procedure ERR_put_error()
      580.   /********************************************************/
      581.   
      582. > void ERR_put_error(int lib, int func, int reason, const char *file,
      583.   	     int line)
      584.   	{

crypto/err/err.c:606:2: Skipping ERR_get_state(): empty list of specs
      604.   	}
      605.   #endif
      606.   	es=ERR_get_state();
              ^
      607.   
      608.   	es->top=(es->top+1)%ERR_NUM_ERRORS;

crypto/err/err.c:608:2: 
      606.   	es=ERR_get_state();
      607.   
      608. > 	es->top=(es->top+1)%ERR_NUM_ERRORS;
      609.   	if (es->top == es->bottom)
      610.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;

crypto/err/err.c:609:6: Taking false branch
      607.   
      608.   	es->top=(es->top+1)%ERR_NUM_ERRORS;
      609.   	if (es->top == es->bottom)
                  ^
      610.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
      611.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);

crypto/err/err.c:611:2: 
      609.   	if (es->top == es->bottom)
      610.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
      611. > 	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
      612.   	es->err_file[es->top]=file;
      613.   	es->err_line[es->top]=line;

crypto/err/err.c:612:2: 
      610.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
      611.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
      612. > 	es->err_file[es->top]=file;
      613.   	es->err_line[es->top]=line;
      614.   	err_clear_data(es,es->top);

crypto/err/err.c:613:2: 
      611.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
      612.   	es->err_file[es->top]=file;
      613. > 	es->err_line[es->top]=line;
      614.   	err_clear_data(es,es->top);
      615.   	}

crypto/err/err.c:614:2: Taking true branch
      612.   	es->err_file[es->top]=file;
      613.   	es->err_line[es->top]=line;
      614.   	err_clear_data(es,es->top);
              ^
      615.   	}
      616.   

crypto/err/err.c:614:2: Taking false branch
      612.   	es->err_file[es->top]=file;
      613.   	es->err_line[es->top]=line;
      614.   	err_clear_data(es,es->top);
              ^
      615.   	}
      616.   

crypto/err/err.c:615:2: return from a call to ERR_put_error
      613.   	es->err_line[es->top]=line;
      614.   	err_clear_data(es,es->top);
      615.   	}
              ^
      616.   
      617.   void ERR_clear_error(void)

crypto/bio/bio_lib.c:74:3: 
    72.   		{
    73.   		BIOerr(BIO_F_BIO_NEW,ERR_R_MALLOC_FAILURE);
    74. > 		return(NULL);
    75.   		}
    76.   	if (!BIO_set(ret,method))

crypto/bio/bio_lib.c:82:2: return from a call to BIO_new
    80.   		}
    81.   	return(ret);
    82.   	}
           ^
    83.   
    84.   int BIO_set(BIO *bio, BIO_METHOD *method)

ssl/ssl_cert.c:677:6: Taking true branch
  675.   	in=BIO_new(BIO_s_file_internal());
  676.   	
  677.   	if (in == NULL)
              ^
  678.   		{
  679.   		SSLerr(SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK,ERR_R_MALLOC_FAILURE);

ssl/ssl_cert.c:679:3: 
  677.   	if (in == NULL)
  678.   		{
  679. > 		SSLerr(SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK,ERR_R_MALLOC_FAILURE);
  680.   		goto err;
  681.   		}

crypto/err/err.c:582:1: start of procedure ERR_put_error()
    580.   /********************************************************/
    581.   
    582. > void ERR_put_error(int lib, int func, int reason, const char *file,
    583.   	     int line)
    584.   	{

crypto/err/err.c:606:2: Skipping ERR_get_state(): empty list of specs
    604.   	}
    605.   #endif
    606.   	es=ERR_get_state();
            ^
    607.   
    608.   	es->top=(es->top+1)%ERR_NUM_ERRORS;

crypto/err/err.c:608:2: 
    606.   	es=ERR_get_state();
    607.   
    608. > 	es->top=(es->top+1)%ERR_NUM_ERRORS;
    609.   	if (es->top == es->bottom)
    610.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;

crypto/err/err.c:609:6: Taking false branch
    607.   
    608.   	es->top=(es->top+1)%ERR_NUM_ERRORS;
    609.   	if (es->top == es->bottom)
                ^
    610.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    611.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);

crypto/err/err.c:611:2: 
    609.   	if (es->top == es->bottom)
    610.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    611. > 	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    612.   	es->err_file[es->top]=file;
    613.   	es->err_line[es->top]=line;

crypto/err/err.c:612:2: 
    610.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    611.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    612. > 	es->err_file[es->top]=file;
    613.   	es->err_line[es->top]=line;
    614.   	err_clear_data(es,es->top);

crypto/err/err.c:613:2: 
    611.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    612.   	es->err_file[es->top]=file;
    613. > 	es->err_line[es->top]=line;
    614.   	err_clear_data(es,es->top);
    615.   	}

crypto/err/err.c:614:2: Taking true branch
    612.   	es->err_file[es->top]=file;
    613.   	es->err_line[es->top]=line;
    614.   	err_clear_data(es,es->top);
            ^
    615.   	}
    616.   

crypto/err/err.c:614:2: Taking false branch
    612.   	es->err_file[es->top]=file;
    613.   	es->err_line[es->top]=line;
    614.   	err_clear_data(es,es->top);
            ^
    615.   	}
    616.   

crypto/err/err.c:615:2: return from a call to ERR_put_error
    613.   	es->err_line[es->top]=line;
    614.   	err_clear_data(es,es->top);
    615.   	}
            ^
    616.   
    617.   void ERR_clear_error(void)

ssl/ssl_cert.c:701:1: 
  699.   	if (0)
  700.   		{
  701. > err:
  702.   		ret=0;
  703.   		}

ssl/ssl_cert.c:702:3: 
  700.   		{
  701.   err:
  702. > 		ret=0;
  703.   		}
  704.   	if(in != NULL)

ssl/ssl_cert.c:704:5: Taking false branch
  702.   		ret=0;
  703.   		}
  704.   	if(in != NULL)
             ^
  705.   		BIO_free(in);
  706.   	if(x != NULL)

ssl/ssl_cert.c:706:5: Taking false branch
  704.   	if(in != NULL)
  705.   		BIO_free(in);
  706.   	if(x != NULL)
             ^
  707.   		X509_free(x);
  708.   	

ssl/ssl_cert.c:709:2: 
  707.   		X509_free(x);
  708.   	
  709. > 	sk_X509_NAME_set_cmp_func(stack,oldcmp);
  710.   
  711.   	return ret;

crypto/stack/stack.c:79:1: start of procedure sk_set_cmp_func()
    77.   #include <errno.h>
    78.   
    79. > int (*sk_set_cmp_func(STACK *sk, int (*c)(const char * const *,const char * const *)))
    80.   		(const char * const *, const char * const *)
    81.   	{

crypto/stack/stack.c:82:2: 
    80.   		(const char * const *, const char * const *)
    81.   	{
    82. > 	int (*old)(const char * const *,const char * const *)=sk->comp;
    83.   
    84.   	if (sk->comp != c)

crypto/stack/stack.c:84:6: Taking true branch
    82.   	int (*old)(const char * const *,const char * const *)=sk->comp;
    83.   
    84.   	if (sk->comp != c)
               ^
    85.   		sk->sorted=0;
    86.   	sk->comp=c;

crypto/stack/stack.c:85:3: 
    83.   
    84.   	if (sk->comp != c)
    85. > 		sk->sorted=0;
    86.   	sk->comp=c;
    87.   

crypto/stack/stack.c:86:2: 
    84.   	if (sk->comp != c)
    85.   		sk->sorted=0;
    86. > 	sk->comp=c;
    87.   
    88.   	return old;

crypto/stack/stack.c:88:2: 
    86.   	sk->comp=c;
    87.   
    88. > 	return old;
    89.   	}
    90.   

crypto/stack/stack.c:89:2: return from a call to sk_set_cmp_func
    87.   
    88.   	return old;
    89.   	}
           ^
    90.   
    91.   STACK *sk_dup(STACK *sk)

ssl/ssl_cert.c:711:2: 
  709.   	sk_X509_NAME_set_cmp_func(stack,oldcmp);
  710.   
  711. > 	return ret;
  712.   	}
  713.   

ssl/ssl_cert.c:712:2: return from a call to SSL_add_file_cert_subjects_to_stack
  710.   
  711.   	return ret;
  712.   	}
          ^
  713.   
  714.   /*!

ssl/ssl_cert.c:762:7: Taking true branch
760.   		if (r <= 0 || r >= sizeof buf)
761.   			goto err;
762.   		if(!SSL_add_file_cert_subjects_to_stack(stack,buf))
             ^
763.   			goto err;
764.   		}
