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


ssl/ssl_cert.c:675:1: start of procedure SSL_add_dir_cert_subjects_to_stack()
673.   #ifndef VMS			/* XXXX This may be fixed in the future */
674.   
675. > int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
676.   				       const char *dir)
677.       {

ssl/ssl_cert.c:680:5: 
678.       DIR *d;
679.       struct dirent *dstruct;
680. >     int ret = 0;
681.   
682.       CRYPTO_w_lock(CRYPTO_LOCK_READDIR);

ssl/ssl_cert.c:682:5: 
680.       int ret = 0;
681.   
682. >     CRYPTO_w_lock(CRYPTO_LOCK_READDIR);
683.       d = opendir(dir);
684.   

crypto/cryptlib.c:191:1: start of procedure CRYPTO_lock()
  189.   	}
  190.   
  191. > void CRYPTO_lock(int mode, int type, const char *file, int line)
  192.   	{
  193.   #ifdef LOCK_DEBUG

crypto/cryptlib.c:216:6: Taking true branch
  214.   		}
  215.   #endif
  216.   	if (locking_callback != NULL)
              ^
  217.   		locking_callback(mode,type,file,line);
  218.   	}

crypto/cryptlib.c:217:3: Skipping __function_pointer__(): unresolved function pointer
  215.   #endif
  216.   	if (locking_callback != NULL)
  217.   		locking_callback(mode,type,file,line);
           ^
  218.   	}
  219.   

crypto/cryptlib.c:216:2: 
  214.   		}
  215.   #endif
  216. > 	if (locking_callback != NULL)
  217.   		locking_callback(mode,type,file,line);
  218.   	}

crypto/cryptlib.c:218:2: return from a call to CRYPTO_lock
  216.   	if (locking_callback != NULL)
  217.   		locking_callback(mode,type,file,line);
  218.   	}
          ^
  219.   
  220.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

ssl/ssl_cert.c:683:5: 
681.   
682.       CRYPTO_w_lock(CRYPTO_LOCK_READDIR);
683. >     d = opendir(dir);
684.   
685.       /* Note that a side effect is that the CAs will be sorted by name */

ssl/ssl_cert.c:686:9: Taking false branch
684.   
685.       /* Note that a side effect is that the CAs will be sorted by name */
686.       if(!d)
               ^
687.   	{
688.   	SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,ERR_R_MALLOC_FAILURE);

ssl/ssl_cert.c:692:12: Loop condition is false. Leaving loop
690.   	}
691.   
692.       while((dstruct=readdir(d)))
                  ^
693.   	{
694.   	char buf[1024];

ssl/ssl_cert.c:706:5: 
704.   	    goto err;
705.   	}
706. >     ret = 1;
707.   
708.   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)
	{
	SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,ERR_R_MALLOC_FAILURE);
	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\tSSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,ERR_R_MALLOC_FAILURE);\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}']