Make sure that the 'config' variable is correctly defined and declared
[openssl.git] / apps / openssl.c
index 7edd9e3132fdd752f56a5f44be192098c545a8ae..d0937156766773662dac7bc667c8b1e15719842e 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 #define OPENSSL_C /* tells apps.h to use complete apps_startup() */
+#include "apps.h"
 #include <openssl/bio.h>
 #include <openssl/crypto.h>
 #include <openssl/lhash.h>
 #include <openssl/ssl.h>
 #include <openssl/engine.h>
 #define USE_SOCKETS /* needed for the _O_BINARY defs in the MS world */
-#include "apps.h"
 #include "progs.h"
 #include "s_apps.h"
 #include <openssl/err.h>
@@ -139,11 +139,11 @@ static unsigned long MS_CALLBACK hash(const void *a_void);
 static int MS_CALLBACK cmp(const void *a_void,const void *b_void);
 static LHASH *prog_init(void );
 static int do_cmd(LHASH *prog,int argc,char *argv[]);
-CONF *config=NULL;
 char *default_config_file=NULL;
 
 /* Make sure there is only one when MONOLITH is defined */
 #ifdef MONOLITH
+CONF *config=NULL;
 BIO *bio_err=NULL;
 #endif
 
@@ -215,8 +215,8 @@ static void lock_dbg_cb(int mode, int type, const char *file, int line)
 int main(int Argc, char *Argv[])
        {
        ARGS arg;
-#define PROG_NAME_SIZE 16
-       char pname[PROG_NAME_SIZE];
+#define PROG_NAME_SIZE 39
+       char pname[PROG_NAME_SIZE+1];
        FUNCTION f,*fp;
        MS_STATIC char *prompt,buf[1024],config_name[256];
        int n,i,ret=0;
@@ -274,7 +274,12 @@ int main(int Argc, char *Argv[])
 
        config=NCONF_new(NULL);
        i=NCONF_load(config,p,&errline);
-       if (i == 0) ERR_clear_error();
+       if (i == 0)
+               {
+               NCONF_free(config);
+               config = NULL;
+               ERR_clear_error();
+               }
 
        prog=prog_init();