X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=apps%2Fopenssl.c;h=02d86d546df3e8198bf7d70d18d0aef2ce9281b1;hb=8c5a2bd6bb9a8c2bb3e1b63c03e57bb1115275d1;hp=d0937156766773662dac7bc667c8b1e15719842e;hpb=0e2cc42cfb4d09c19140f89853e3f0cf4d8c5142;p=oweals%2Fopenssl.git diff --git a/apps/openssl.c b/apps/openssl.c index d093715676..02d86d546d 100644 --- a/apps/openssl.c +++ b/apps/openssl.c @@ -122,7 +122,9 @@ #include #include #include +#ifndef OPENSSL_NO_ENGINE #include +#endif #define USE_SOCKETS /* needed for the _O_BINARY defs in the MS world */ #include "progs.h" #include "s_apps.h" @@ -161,7 +163,7 @@ static void lock_dbg_cb(int mode, int type, const char *file, int line) goto err; } - if (type < 0 || type > CRYPTO_NUM_LOCKS) + if (type < 0 || type >= CRYPTO_NUM_LOCKS) { errstr = "type out of bounds"; goto err; @@ -218,7 +220,9 @@ int main(int Argc, char *Argv[]) #define PROG_NAME_SIZE 39 char pname[PROG_NAME_SIZE+1]; FUNCTION f,*fp; - MS_STATIC char *prompt,buf[1024],config_name[256]; + MS_STATIC const char *prompt; + MS_STATIC char buf[1024]; + char *to_free=NULL; int n,i,ret=0; int argc; char **argv,*p; @@ -228,6 +232,10 @@ int main(int Argc, char *Argv[]) arg.data=NULL; arg.count=0; + if (bio_err == NULL) + if ((bio_err=BIO_new(BIO_s_file())) != NULL) + BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); + if (getenv("OPENSSL_DEBUG_MEMORY") != NULL) /* if not defined, use compiled-in library defaults */ { if (!(0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off"))) @@ -252,23 +260,12 @@ int main(int Argc, char *Argv[]) apps_startup(); - if (bio_err == NULL) - if ((bio_err=BIO_new(BIO_s_file())) != NULL) - BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); - /* Lets load up our environment a little */ p=getenv("OPENSSL_CONF"); if (p == NULL) p=getenv("SSLEAY_CONF"); if (p == NULL) - { - strcpy(config_name,X509_get_default_cert_area()); -#ifndef OPENSSL_SYS_VMS - strcat(config_name,"/"); -#endif - strcat(config_name,OPENSSL_CONF); - p=config_name; - } + p=to_free=make_config_name(); default_config_file=p; @@ -284,7 +281,7 @@ int main(int Argc, char *Argv[]) prog=prog_init(); /* first check the program name */ - program_name(Argv[0],pname,PROG_NAME_SIZE); + program_name(Argv[0],pname,sizeof pname); f.name=pname; fp=(FUNCTION *)lh_retrieve(prog,&f); @@ -312,7 +309,7 @@ int main(int Argc, char *Argv[]) { ret=0; p=buf; - n=1024; + n=sizeof buf; i=0; for (;;) { @@ -346,6 +343,8 @@ int main(int Argc, char *Argv[]) BIO_printf(bio_err,"bad exit\n"); ret=1; end: + if (to_free) + OPENSSL_free(to_free); if (config != NULL) { NCONF_free(config); @@ -362,7 +361,7 @@ end: BIO_free(bio_err); bio_err=NULL; } - EXIT(ret); + OPENSSL_EXIT(ret); } #define LIST_STANDARD_COMMANDS "list-standard-commands" @@ -490,7 +489,7 @@ static LHASH *prog_init(void) { LHASH *ret; FUNCTION *f; - int i; + size_t i; /* Purely so it looks nice when the user hits ? */ for(i=0,f=functions ; f->name != NULL ; ++f,++i) @@ -508,12 +507,12 @@ static LHASH *prog_init(void) /* static int MS_CALLBACK cmp(FUNCTION *a, FUNCTION *b) */ static int MS_CALLBACK cmp(const void *a_void, const void *b_void) { - return(strncmp(((FUNCTION *)a_void)->name, - ((FUNCTION *)b_void)->name,8)); + return(strncmp(((const FUNCTION *)a_void)->name, + ((const FUNCTION *)b_void)->name,8)); } /* static unsigned long MS_CALLBACK hash(FUNCTION *a) */ static unsigned long MS_CALLBACK hash(const void *a_void) { - return(lh_strhash(((FUNCTION *)a_void)->name)); + return(lh_strhash(((const FUNCTION *)a_void)->name)); }