From 27498a33307b9e79f93f13bb2841f32ce8b2783e Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Tue, 3 Dec 2002 16:34:28 +0000 Subject: [PATCH] EXIT() may mean return(). That's confusing, so let's have it really mean exit() in whatever way works for the intended platform, and define OPENSSL_EXIT() to have the old meaning (the name is of course because it's only used in the openssl program) --- apps/asn1pars.c | 2 +- apps/ca.c | 2 +- apps/ciphers.c | 2 +- apps/crl.c | 2 +- apps/crl2p7.c | 2 +- apps/dgst.c | 2 +- apps/dh.c | 2 +- apps/dhparam.c | 2 +- apps/dsa.c | 2 +- apps/dsaparam.c | 2 +- apps/enc.c | 2 +- apps/engine.c | 2 +- apps/errstr.c | 2 +- apps/gendh.c | 2 +- apps/gendsa.c | 2 +- apps/genrsa.c | 2 +- apps/nseq.c | 4 ++-- apps/ocsp.c | 2 +- apps/openssl.c | 2 +- apps/passwd.c | 4 ++-- apps/pkcs12.c | 2 +- apps/pkcs7.c | 2 +- apps/rand.c | 2 +- apps/req.c | 2 +- apps/rsa.c | 2 +- apps/s_client.c | 2 +- apps/s_server.c | 2 +- apps/s_time.c | 2 +- apps/sess_id.c | 2 +- apps/speed.c | 2 +- apps/spkac.c | 2 +- apps/verify.c | 2 +- apps/version.c | 2 +- apps/x509.c | 2 +- e_os.h | 30 +++++++++++++++--------------- 35 files changed, 51 insertions(+), 51 deletions(-) diff --git a/apps/asn1pars.c b/apps/asn1pars.c index 8f178db851..8367415405 100644 --- a/apps/asn1pars.c +++ b/apps/asn1pars.c @@ -332,6 +332,6 @@ end: if (osk != NULL) sk_free(osk); OBJ_cleanup(); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } diff --git a/apps/ca.c b/apps/ca.c index 811413df4a..705c705c0a 100644 --- a/apps/ca.c +++ b/apps/ca.c @@ -1647,7 +1647,7 @@ err: NCONF_free(conf); OBJ_cleanup(); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } static void lookup_fail(char *name, char *tag) diff --git a/apps/ciphers.c b/apps/ciphers.c index fe26ae8cd6..7c62fc5dc3 100644 --- a/apps/ciphers.c +++ b/apps/ciphers.c @@ -203,6 +203,6 @@ end: if (ssl != NULL) SSL_free(ssl); if (STDout != NULL) BIO_free_all(STDout); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } diff --git a/apps/crl.c b/apps/crl.c index 00946b4d20..c6089ace52 100644 --- a/apps/crl.c +++ b/apps/crl.c @@ -377,7 +377,7 @@ end: X509_STORE_free(store); } apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } static X509_CRL *load_crl(char *infile, int format) diff --git a/apps/crl2p7.c b/apps/crl2p7.c index 8729068462..b2f2d121d5 100644 --- a/apps/crl2p7.c +++ b/apps/crl2p7.c @@ -280,7 +280,7 @@ end: if (crl != NULL) X509_CRL_free(crl); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } /* diff --git a/apps/dgst.c b/apps/dgst.c index c4bb7a1061..280f79b4a2 100644 --- a/apps/dgst.c +++ b/apps/dgst.c @@ -365,7 +365,7 @@ end: if(sigbuf) OPENSSL_free(sigbuf); if (bmd != NULL) BIO_free(bmd); apps_shutdown(); - EXIT(err); + OPENSSL_EXIT(err); } int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout, diff --git a/apps/dh.c b/apps/dh.c index 27c3dc8df2..c10ea96b90 100644 --- a/apps/dh.c +++ b/apps/dh.c @@ -333,6 +333,6 @@ end: if (out != NULL) BIO_free_all(out); if (dh != NULL) DH_free(dh); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } #endif diff --git a/apps/dhparam.c b/apps/dhparam.c index ea15ef3236..cbc65bcc5f 100644 --- a/apps/dhparam.c +++ b/apps/dhparam.c @@ -519,7 +519,7 @@ end: if (out != NULL) BIO_free_all(out); if (dh != NULL) DH_free(dh); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } /* dh_cb is identical to dsa_cb in apps/dsaparam.c */ diff --git a/apps/dsa.c b/apps/dsa.c index 9da1a41645..65988717bb 100644 --- a/apps/dsa.c +++ b/apps/dsa.c @@ -314,6 +314,6 @@ end: if(passin) OPENSSL_free(passin); if(passout) OPENSSL_free(passout); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } #endif diff --git a/apps/dsaparam.c b/apps/dsaparam.c index 2f436803e3..320d76f632 100644 --- a/apps/dsaparam.c +++ b/apps/dsaparam.c @@ -372,7 +372,7 @@ end: if (out != NULL) BIO_free_all(out); if (dsa != NULL) DSA_free(dsa); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } static void MS_CALLBACK dsa_cb(int p, int n, void *arg) diff --git a/apps/enc.c b/apps/enc.c index bae7f21d79..42ddfd244b 100644 --- a/apps/enc.c +++ b/apps/enc.c @@ -586,7 +586,7 @@ end: if (b64 != NULL) BIO_free(b64); if(pass) OPENSSL_free(pass); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } int set_hex(char *in, unsigned char *out, int size) diff --git a/apps/engine.c b/apps/engine.c index 734ecb3e5d..b718ae124c 100644 --- a/apps/engine.c +++ b/apps/engine.c @@ -516,5 +516,5 @@ end: sk_pop_free(post_cmds, identity); if (bio_out != NULL) BIO_free_all(bio_out); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } diff --git a/apps/errstr.c b/apps/errstr.c index fedb568d68..19489b0df3 100644 --- a/apps/errstr.c +++ b/apps/errstr.c @@ -122,5 +122,5 @@ int MAIN(int argc, char **argv) } } apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } diff --git a/apps/gendh.c b/apps/gendh.c index f2542960bf..98ee413c74 100644 --- a/apps/gendh.c +++ b/apps/gendh.c @@ -198,7 +198,7 @@ end: if (out != NULL) BIO_free_all(out); if (dh != NULL) DH_free(dh); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } static void MS_CALLBACK dh_cb(int p, int n, void *arg) diff --git a/apps/gendsa.c b/apps/gendsa.c index 1e1e9f3e4c..4600711c36 100644 --- a/apps/gendsa.c +++ b/apps/gendsa.c @@ -246,6 +246,6 @@ end: if (dsa != NULL) DSA_free(dsa); if(passout) OPENSSL_free(passout); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } #endif diff --git a/apps/genrsa.c b/apps/genrsa.c index 515bd7c901..dbc23e40aa 100644 --- a/apps/genrsa.c +++ b/apps/genrsa.c @@ -258,7 +258,7 @@ err: if (ret != 0) ERR_print_errors(bio_err); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } static void MS_CALLBACK genrsa_cb(int p, int n, void *arg) diff --git a/apps/nseq.c b/apps/nseq.c index c26f62cb61..dc71d45012 100644 --- a/apps/nseq.c +++ b/apps/nseq.c @@ -102,7 +102,7 @@ int MAIN(int argc, char **argv) BIO_printf (bio_err, "-in file input file\n"); BIO_printf (bio_err, "-out file output file\n"); BIO_printf (bio_err, "-toseq output NS Sequence file\n"); - EXIT(1); + OPENSSL_EXIT(1); } if (infile) { @@ -162,6 +162,6 @@ end: BIO_free_all(out); NETSCAPE_CERT_SEQUENCE_free(seq); - EXIT(ret); + OPENSSL_EXIT(ret); } diff --git a/apps/ocsp.c b/apps/ocsp.c index d759b2709c..92922bc8ad 100644 --- a/apps/ocsp.c +++ b/apps/ocsp.c @@ -899,7 +899,7 @@ end: SSL_CTX_free(ctx); } - EXIT(ret); + OPENSSL_EXIT(ret); } static int add_ocsp_cert(OCSP_REQUEST **req, X509 *cert, X509 *issuer, diff --git a/apps/openssl.c b/apps/openssl.c index 45f8d7f4ef..47896472e8 100644 --- a/apps/openssl.c +++ b/apps/openssl.c @@ -358,7 +358,7 @@ end: BIO_free(bio_err); bio_err=NULL; } - EXIT(ret); + OPENSSL_EXIT(ret); } #define LIST_STANDARD_COMMANDS "list-standard-commands" diff --git a/apps/passwd.c b/apps/passwd.c index 0c2cf62e8b..3ad91d89d6 100644 --- a/apps/passwd.c +++ b/apps/passwd.c @@ -292,7 +292,7 @@ err: if (out) BIO_free_all(out); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } @@ -505,6 +505,6 @@ err: int MAIN(int argc, char **argv) { fputs("Program not available.\n", stderr) - EXIT(1); + OPENSSL_EXIT(1); } #endif diff --git a/apps/pkcs12.c b/apps/pkcs12.c index bb11e26723..8d1babe5ea 100644 --- a/apps/pkcs12.c +++ b/apps/pkcs12.c @@ -696,7 +696,7 @@ int MAIN(int argc, char **argv) if(passin) OPENSSL_free(passin); if(passout) OPENSSL_free(passout); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass, diff --git a/apps/pkcs7.c b/apps/pkcs7.c index 0cced40f0f..738dd853ce 100644 --- a/apps/pkcs7.c +++ b/apps/pkcs7.c @@ -301,5 +301,5 @@ end: if (in != NULL) BIO_free(in); if (out != NULL) BIO_free_all(out); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } diff --git a/apps/rand.c b/apps/rand.c index f51f5bec35..eaaa6e35a6 100644 --- a/apps/rand.c +++ b/apps/rand.c @@ -213,5 +213,5 @@ err: if (out) BIO_free_all(out); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } diff --git a/apps/req.c b/apps/req.c index c2bada07c8..d8f3611ace 100644 --- a/apps/req.c +++ b/apps/req.c @@ -1075,7 +1075,7 @@ end: if (dsa_params != NULL) DSA_free(dsa_params); #endif apps_shutdown(); - EXIT(ex); + OPENSSL_EXIT(ex); } static int make_REQ(X509_REQ *req, EVP_PKEY *pkey, char *subj, int attribs, diff --git a/apps/rsa.c b/apps/rsa.c index 4e19bc16fb..aebec744a2 100644 --- a/apps/rsa.c +++ b/apps/rsa.c @@ -369,7 +369,7 @@ end: if(passin) OPENSSL_free(passin); if(passout) OPENSSL_free(passout); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } #else /* !OPENSSL_NO_RSA */ diff --git a/apps/s_client.c b/apps/s_client.c index 7b1fa7b22b..738588c6aa 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -917,7 +917,7 @@ end: bio_c_out=NULL; } apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } diff --git a/apps/s_server.c b/apps/s_server.c index 94dd59becc..44886c5c26 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -868,7 +868,7 @@ end: bio_s_out=NULL; } apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } static void print_stats(BIO *bio, SSL_CTX *ssl_ctx) diff --git a/apps/s_time.c b/apps/s_time.c index 181a7c82f6..1ad16cd607 100644 --- a/apps/s_time.c +++ b/apps/s_time.c @@ -642,7 +642,7 @@ end: tm_ctx=NULL; } apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } /*********************************************************************** diff --git a/apps/sess_id.c b/apps/sess_id.c index 41c3b3f4a3..d91d84d220 100644 --- a/apps/sess_id.c +++ b/apps/sess_id.c @@ -273,7 +273,7 @@ end: if (out != NULL) BIO_free_all(out); if (x != NULL) SSL_SESSION_free(x); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } static SSL_SESSION *load_sess_id(char *infile, int format) diff --git a/apps/speed.c b/apps/speed.c index b5e17a1f29..7f42b52e73 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -1729,7 +1729,7 @@ end: DSA_free(dsa_key[i]); #endif apps_shutdown(); - EXIT(mret); + OPENSSL_EXIT(mret); } static void print_message(const char *s, long num, int length) diff --git a/apps/spkac.c b/apps/spkac.c index 4ce53e36c9..ed370c5ca9 100644 --- a/apps/spkac.c +++ b/apps/spkac.c @@ -295,5 +295,5 @@ end: EVP_PKEY_free(pkey); if(passin) OPENSSL_free(passin); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } diff --git a/apps/verify.c b/apps/verify.c index e4cbceaf8e..9a18213ece 100644 --- a/apps/verify.c +++ b/apps/verify.c @@ -232,7 +232,7 @@ end: sk_X509_pop_free(untrusted, X509_free); sk_X509_pop_free(trusted, X509_free); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } static int check(X509_STORE *ctx, char *file, STACK_OF(X509) *uchain, STACK_OF(X509) *tchain, int purpose, ENGINE *e) diff --git a/apps/version.c b/apps/version.c index 0cbcb47f88..0843b67565 100644 --- a/apps/version.c +++ b/apps/version.c @@ -200,5 +200,5 @@ int MAIN(int argc, char **argv) if (dir) printf("%s\n",SSLeay_version(SSLEAY_DIR)); end: apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } diff --git a/apps/x509.c b/apps/x509.c index 8c057be214..7915eca65c 100644 --- a/apps/x509.c +++ b/apps/x509.c @@ -1017,7 +1017,7 @@ end: sk_ASN1_OBJECT_pop_free(reject, ASN1_OBJECT_free); if (passin) OPENSSL_free(passin); apps_shutdown(); - EXIT(ret); + OPENSSL_EXIT(ret); } static ASN1_INTEGER *load_serial(char *CAfile, char *serialfile, int create) diff --git a/e_os.h b/e_os.h index 5d761781b8..db9ba97ec8 100644 --- a/e_os.h +++ b/e_os.h @@ -243,10 +243,11 @@ extern "C" { # define _kbhit kbhit # endif -# if defined(WIN16) && !defined(MONOLITH) && defined(SSLEAY) && defined(_WINEXITNOPERSIST) -# define EXIT(n) do { if (n == 0) _wsetexit(_WINEXITNOPERSIST); return(n); } while(0) +# if defined(WIN16) && defined(SSLEAY) && defined(_WINEXITNOPERSIST) +# define EXIT(n) _wsetexit(_WINEXITNOPERSIST) +# define OPENSSL_EXIT(n) do { if (n == 0) EXIT(n); return(n); } while(0) # else -# define EXIT(n) return(n) +# define EXIT(n) return(n) # endif # define LIST_SEPARATOR_CHAR ';' # ifndef X_OK @@ -302,18 +303,13 @@ extern "C" { the status is tagged as an error, which I believe is what is wanted here. -- Richard Levitte */ -# if !defined(MONOLITH) || defined(OPENSSL_C) -# define EXIT(n) do { int __VMS_EXIT = n; \ +# define EXIT(n) do { int __VMS_EXIT = n; \ if (__VMS_EXIT == 0) \ __VMS_EXIT = 1; \ else \ __VMS_EXIT = (n << 3) | 2; \ __VMS_EXIT |= 0x10000000; \ - exit(__VMS_EXIT); \ - return(__VMS_EXIT); } while(0) -# else -# define EXIT(n) return(n) -# endif + exit(__VMS_EXIT); } while(0) # define NO_SYS_PARAM_H # else /* !defined VMS */ @@ -344,11 +340,7 @@ extern "C" { # define RFILE ".rnd" # define LIST_SEPARATOR_CHAR ':' # define NUL_DEV "/dev/null" -# ifndef MONOLITH -# define EXIT(n) do { exit(n); return(n); } while(0) -# else -# define EXIT(n) return(n) -# endif +# define EXIT(n) exit(n) # endif # define SSLeay_getpid() getpid() @@ -475,6 +467,14 @@ extern char *sys_errlist[]; extern int sys_nerr; (((errnum)<0 || (errnum)>=sys_nerr) ? NULL : sys_errlist[errnum]) #endif +#ifndef OPENSSL_EXIT +# if defined(MONOLITH) && !defined(OPENSSL_C) +# define OPENSSL_EXIT(n) return(n) +# else +# define OPENSSL_EXIT(n) do { EXIT(n); return(n); } while(0) +# endif +#endif + /***********************************************/ /* do we need to do this for getenv. -- 2.25.1