X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=apps%2Flib%2Fapps.c;h=3e4cc288b1512d7162fb01b8c1ba201aca26ae76;hp=4337cc6c87c9aef4bd6a6e7baf78f10cec2b1f71;hb=c996f71bab433c5d0f75945206a8cfd422829a49;hpb=538404d2186954d58c04c46232f985ddf9675b6f diff --git a/apps/lib/apps.c b/apps/lib/apps.c index 4337cc6c87..3e4cc288b1 100644 --- a/apps/lib/apps.c +++ b/apps/lib/apps.c @@ -438,10 +438,6 @@ X509 *load_cert_pass(const char *uri, int maybe_stdin, if (desc == NULL) desc = "certificate"; - if (uri == NULL) { - unbuffer(stdin); - uri = ""; - } (void)load_key_cert_crl(uri, maybe_stdin, pass, desc, NULL, &cert, NULL); if (cert == NULL) { BIO_printf(bio_err, "Unable to load %s\n", desc); @@ -453,7 +449,7 @@ X509 *load_cert_pass(const char *uri, int maybe_stdin, /* the format parameter is meanwhile not needed anymore and thus ignored */ X509 *load_cert(const char *uri, int format, const char *desc) { - return load_cert_pass(uri, 0, NULL, desc); + return load_cert_pass(uri, 1, NULL, desc); } /* the format parameter is meanwhile not needed anymore and thus ignored */ @@ -671,16 +667,24 @@ static int load_certs_crls(const char *file, int format, return rv; } +void app_bail_out(char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + BIO_vprintf(bio_err, fmt, args); + va_end(args); + ERR_print_errors(bio_err); + exit(1); +} + void* app_malloc(int sz, const char *what) { void *vp = OPENSSL_malloc(sz); - if (vp == NULL) { - BIO_printf(bio_err, "%s: Could not allocate %d bytes for %s\n", - opt_getprog(), sz, what); - ERR_print_errors(bio_err); - exit(1); - } + if (vp == NULL) + app_bail_out("%s: Could not allocate %d bytes for %s\n", + opt_getprog(), sz, what); return vp; } @@ -1152,9 +1156,8 @@ ENGINE *setup_engine_methods(const char *id, unsigned int methods, int debug) void release_engine(ENGINE *e) { #ifndef OPENSSL_NO_ENGINE - if (e != NULL) - /* Free our "structural" reference. */ - ENGINE_free(e); + /* Free our "structural" reference. */ + ENGINE_free(e); #endif } @@ -1627,7 +1630,7 @@ X509_NAME *parse_name(const char *cp, long chtype, int canmulti) goto err; } - while (*cp) { + while (*cp != '\0') { char *bp = work; char *typestr = bp; unsigned char *valstr; @@ -1636,12 +1639,12 @@ X509_NAME *parse_name(const char *cp, long chtype, int canmulti) nextismulti = 0; /* Collect the type */ - while (*cp && *cp != '=') + while (*cp != '\0' && *cp != '=') *bp++ = *cp++; if (*cp == '\0') { BIO_printf(bio_err, - "%s: Hit end of string before finding the '='\n", - opt_getprog()); + "%s: Hit end of string before finding the '='\n", + opt_getprog()); goto err; } *bp++ = '\0'; @@ -1649,7 +1652,7 @@ X509_NAME *parse_name(const char *cp, long chtype, int canmulti) /* Collect the value. */ valstr = (unsigned char *)bp; - for (; *cp && *cp != '/'; *bp++ = *cp++) { + for (; *cp != '\0' && *cp != '/'; *bp++ = *cp++) { if (canmulti && *cp == '+') { nextismulti = 1; break; @@ -1664,7 +1667,7 @@ X509_NAME *parse_name(const char *cp, long chtype, int canmulti) *bp++ = '\0'; /* If not at EOS (must be + or /), move forward. */ - if (*cp) + if (*cp != '\0') ++cp; /* Parse */ @@ -1683,6 +1686,7 @@ X509_NAME *parse_name(const char *cp, long chtype, int canmulti) if (!X509_NAME_add_entry_by_NID(n, nid, chtype, valstr, strlen((char *)valstr), -1, ismulti ? -1 : 0)) { + ERR_print_errors(bio_err); BIO_printf(bio_err, "%s: Error adding name attribute \"/%s=%s\"\n", opt_getprog(), typestr ,valstr); goto err; @@ -2230,70 +2234,23 @@ double app_tminterval(int stop, int usertime) return ret; } -#elif defined(OPENSSL_SYSTEM_VMS) -# include -# include - -double app_tminterval(int stop, int usertime) -{ - static clock_t tmstart; - double ret = 0; - clock_t now; -# ifdef __TMS - struct tms rus; - - now = times(&rus); - if (usertime) - now = rus.tms_utime; -# else - if (usertime) - now = clock(); /* sum of user and kernel times */ - else { - struct timeval tv; - gettimeofday(&tv, NULL); - now = (clock_t)((unsigned long long)tv.tv_sec * CLK_TCK + - (unsigned long long)tv.tv_usec * (1000000 / CLK_TCK) - ); - } -# endif - if (stop == TM_START) - tmstart = now; - else - ret = (now - tmstart) / (double)(CLK_TCK); - - return ret; -} - #elif defined(_SC_CLK_TCK) /* by means of unistd.h */ # include double app_tminterval(int stop, int usertime) { double ret = 0; - clock_t now; - static clock_t tmstart; - long int tck = sysconf(_SC_CLK_TCK); -# ifdef __TMS struct tms rus; + clock_t now = times(&rus); + static clock_t tmstart; - now = times(&rus); if (usertime) now = rus.tms_utime; -# else - if (usertime) - now = clock(); /* sum of user and kernel times */ - else { - struct timeval tv; - gettimeofday(&tv, NULL); - now = (clock_t)((unsigned long long)tv.tv_sec * tck + - (unsigned long long)tv.tv_usec * (1000000 / tck) - ); - } -# endif if (stop == TM_START) { tmstart = now; } else { + long int tck = sysconf(_SC_CLK_TCK); ret = (now - tmstart) / (double)tck; }