ssl/ssl_cert.c:743: error: RESOURCE_LEAK
  resource acquired to `ret` by call to `opendir()` at line 718, column 9 is not released after line 743, column 5.
Showing all 12 steps of the trace


ssl/ssl_cert.c:710:1: start of procedure SSL_add_dir_cert_subjects_to_stack()
708.   #ifndef MAC_OS_pre_X
709.   
710. > int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
711.   				       const char *dir)
712.       {

ssl/ssl_cert.c:715:5: 
713.       DIR *d;
714.       struct dirent *dstruct;
715. >     int ret = 0;
716.   
717.       CRYPTO_w_lock(CRYPTO_LOCK_READDIR);

ssl/ssl_cert.c:717:5: 
715.       int ret = 0;
716.   
717. >     CRYPTO_w_lock(CRYPTO_LOCK_READDIR);
718.       d = opendir(dir);
719.   

crypto/cryptlib.c:197:1: start of procedure CRYPTO_lock()
  195.   	}
  196.   
  197. > void CRYPTO_lock(int mode, int type, const char *file, int line)
  198.   	{
  199.   #ifdef LOCK_DEBUG

crypto/cryptlib.c:222:6: Taking true branch
  220.   		}
  221.   #endif
  222.   	if (locking_callback != NULL)
              ^
  223.   		locking_callback(mode,type,file,line);
  224.   	}

crypto/cryptlib.c:223:3: Skipping __function_pointer__(): unresolved function pointer
  221.   #endif
  222.   	if (locking_callback != NULL)
  223.   		locking_callback(mode,type,file,line);
           ^
  224.   	}
  225.   

crypto/cryptlib.c:222:2: 
  220.   		}
  221.   #endif
  222. > 	if (locking_callback != NULL)
  223.   		locking_callback(mode,type,file,line);
  224.   	}

crypto/cryptlib.c:224:2: return from a call to CRYPTO_lock
  222.   	if (locking_callback != NULL)
  223.   		locking_callback(mode,type,file,line);
  224.   	}
          ^
  225.   
  226.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

ssl/ssl_cert.c:718:5: 
716.   
717.       CRYPTO_w_lock(CRYPTO_LOCK_READDIR);
718. >     d = opendir(dir);
719.   
720.       /* Note that a side effect is that the CAs will be sorted by name */

ssl/ssl_cert.c:721:9: Taking false branch
719.   
720.       /* Note that a side effect is that the CAs will be sorted by name */
721.       if(!d)
               ^
722.   	{
723.   	SYSerr(SYS_F_OPENDIR, get_last_sys_error());

ssl/ssl_cert.c:729:12: Loop condition is false. Leaving loop
727.   	}
728.   
729.       while((dstruct=readdir(d)))
                  ^
730.   	{
731.   	char buf[1024];

ssl/ssl_cert.c:743:5: 
741.   	    goto err;
742.   	}
743. >     ret = 1;
744.   
745.   err:	

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];
	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;
	    }
	sprintf(buf,"%s/%s",dir,dstruct->d_name);
	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    {\n    DIR *d;\n    struct dirent *dstruct;\n    int ret = 0;\n    CRYPTO_w_lock(CRYPTO_LOCK_READDIR);\n    d = opendir(dir);\n    if(!d)\n\t{\n\tSYSerr(SYS_F_OPENDIR, get_last_sys_error());\n\tERR_add_error_data(3, "opendir(\'", dir, "\')");\n\tSSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK, ERR_R_SYS_LIB);\n\tgoto err;\n\t}\n    while((dstruct=readdir(d)))\n\t{\n\tchar buf[1024];\n\tif(strlen(dir)+strlen(dstruct->d_name)+2 > sizeof buf)\n\t    {\n\t    SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,SSL_R_PATH_TOO_LONG);\n\t    goto err;\n\t    }\n\tsprintf(buf,"%s/%s",dir,dstruct->d_name);\n\tif(!SSL_add_file_cert_subjects_to_stack(stack,buf))\n\t    goto err;\n\t}\n    ret = 1;\nerr:\n    CRYPTO_w_unlock(CRYPTO_LOCK_READDIR);\n    return ret;\n    }', '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 (locking_callback != NULL)\n\t\tlocking_callback(mode,type,file,line);\n\t}']