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


ssl/ssl_cert.c:722:1: start of procedure SSL_add_dir_cert_subjects_to_stack()
720.   #ifndef MAC_OS_pre_X
721.   
722. > int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
723.   				       const char *dir)
724.   	{

ssl/ssl_cert.c:727:2: 
725.   	DIR *d;
726.   	struct dirent *dstruct;
727. > 	int ret = 0;
728.   
729.   	CRYPTO_w_lock(CRYPTO_LOCK_READDIR);

ssl/ssl_cert.c:729:2: 
727.   	int ret = 0;
728.   
729. > 	CRYPTO_w_lock(CRYPTO_LOCK_READDIR);
730.   	d = opendir(dir);
731.   

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

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

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

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

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

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

ssl/ssl_cert.c:730:2: 
728.   
729.   	CRYPTO_w_lock(CRYPTO_LOCK_READDIR);
730. > 	d = opendir(dir);
731.   
732.   	/* Note that a side effect is that the CAs will be sorted by name */

ssl/ssl_cert.c:733:6: Taking false branch
731.   
732.   	/* Note that a side effect is that the CAs will be sorted by name */
733.   	if(!d)
            ^
734.   		{
735.   		SYSerr(SYS_F_OPENDIR, get_last_sys_error());

ssl/ssl_cert.c:741:9: Loop condition is true. Entering loop body
739.   		}
740.   	
741.   	while((dstruct=readdir(d)))
               ^
742.   		{
743.   		char buf[1024];

ssl/ssl_cert.c:746:6: Taking false branch
744.   		int r;
745.   		
746.   		if(strlen(dir)+strlen(dstruct->d_name)+2 > sizeof buf)
            ^
747.   			{
748.   			SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,SSL_R_PATH_TOO_LONG);

ssl/ssl_cert.c:752:3: Skipping BIO_snprintf(): empty list of specs
750.   			}
751.   		
752.   		r = BIO_snprintf(buf,sizeof buf,"%s/%s",dir,dstruct->d_name);
         ^
753.   		if (r <= 0 || r >= sizeof buf)
754.   			goto err;

ssl/ssl_cert.c:753:7: Taking false branch
751.   		
752.   		r = BIO_snprintf(buf,sizeof buf,"%s/%s",dir,dstruct->d_name);
753.   		if (r <= 0 || r >= sizeof buf)
             ^
754.   			goto err;
755.   		if(!SSL_add_file_cert_subjects_to_stack(stack,buf))

ssl/ssl_cert.c:753:17: Taking false branch
751.   		
752.   		r = BIO_snprintf(buf,sizeof buf,"%s/%s",dir,dstruct->d_name);
753.   		if (r <= 0 || r >= sizeof buf)
                       ^
754.   			goto err;
755.   		if(!SSL_add_file_cert_subjects_to_stack(stack,buf))

ssl/ssl_cert.c:755:7: Taking true branch
753.   		if (r <= 0 || r >= sizeof buf)
754.   			goto err;
755.   		if(!SSL_add_file_cert_subjects_to_stack(stack,buf))
             ^
756.   			goto err;
757.   		}

int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
				       const char *dir)
	{
	DIR *d;
	struct dirent *dstruct;
	int ret = 0;
	CRYPTO_w_lock(CRYPTO_LOCK_READDIR);
	d = opendir(dir);
	if(!d)
		{
		SYSerr(SYS_F_OPENDIR, get_last_sys_error());
		ERR_add_error_data(3, "opendir('", dir, "')");
		SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK, ERR_R_SYS_LIB);
		goto err;
		}
	while((dstruct=readdir(d)))
		{
		char buf[1024];
		int r;
		if(strlen(dir)+strlen(dstruct->d_name)+2 > sizeof buf)
			{
			SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,SSL_R_PATH_TOO_LONG);
			goto err;
			}
		r = BIO_snprintf(buf,sizeof buf,"%s/%s",dir,dstruct->d_name);
		if (r <= 0 || r >= sizeof buf)
			goto err;
		if(!SSL_add_file_cert_subjects_to_stack(stack,buf))
			goto err;
		}
	ret = 1;
err:
	CRYPTO_w_unlock(CRYPTO_LOCK_READDIR);
	return ret;
	}
['int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,\n\t\t\t\t       const char *dir)\n\t{\n\tDIR *d;\n\tstruct dirent *dstruct;\n\tint ret = 0;\n\tCRYPTO_w_lock(CRYPTO_LOCK_READDIR);\n\td = opendir(dir);\n\tif(!d)\n\t\t{\n\t\tSYSerr(SYS_F_OPENDIR, get_last_sys_error());\n\t\tERR_add_error_data(3, "opendir(\'", dir, "\')");\n\t\tSSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK, ERR_R_SYS_LIB);\n\t\tgoto err;\n\t\t}\n\twhile((dstruct=readdir(d)))\n\t\t{\n\t\tchar buf[1024];\n\t\tint r;\n\t\tif(strlen(dir)+strlen(dstruct->d_name)+2 > sizeof buf)\n\t\t\t{\n\t\t\tSSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,SSL_R_PATH_TOO_LONG);\n\t\t\tgoto err;\n\t\t\t}\n\t\tr = BIO_snprintf(buf,sizeof buf,"%s/%s",dir,dstruct->d_name);\n\t\tif (r <= 0 || r >= sizeof buf)\n\t\t\tgoto err;\n\t\tif(!SSL_add_file_cert_subjects_to_stack(stack,buf))\n\t\t\tgoto err;\n\t\t}\n\tret = 1;\nerr:\n\tCRYPTO_w_unlock(CRYPTO_LOCK_READDIR);\n\treturn ret;\n\t}', 'void CRYPTO_lock(int mode, int type, const char *file, int line)\n\t{\n#ifdef LOCK_DEBUG\n\t\t{\n\t\tchar *rw_text,*operation_text;\n\t\tif (mode & CRYPTO_LOCK)\n\t\t\toperation_text="lock  ";\n\t\telse if (mode & CRYPTO_UNLOCK)\n\t\t\toperation_text="unlock";\n\t\telse\n\t\t\toperation_text="ERROR ";\n\t\tif (mode & CRYPTO_READ)\n\t\t\trw_text="r";\n\t\telse if (mode & CRYPTO_WRITE)\n\t\t\trw_text="w";\n\t\telse\n\t\t\trw_text="ERROR";\n\t\tfprintf(stderr,"lock:%08lx:(%s)%s %-18s %s:%d\\n",\n\t\t\tCRYPTO_thread_id(), rw_text, operation_text,\n\t\t\tCRYPTO_get_lock_name(type), file, line);\n\t\t}\n#endif\n\tif (type < 0)\n\t\t{\n\t\tstruct CRYPTO_dynlock_value *pointer\n\t\t\t= CRYPTO_get_dynlock_value(type);\n\t\tif (pointer && dynlock_lock_callback)\n\t\t\t{\n\t\t\tdynlock_lock_callback(mode, pointer, file, line);\n\t\t\t}\n\t\tCRYPTO_destroy_dynlockid(type);\n\t\t}\n\telse\n\t\tif (locking_callback != NULL)\n\t\t\tlocking_callback(mode,type,file,line);\n\t}']