From 27c7609cf8e72dfa2956bc00f166301ee983581a Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Thu, 22 Jan 2015 12:57:29 -0500 Subject: [PATCH] ifdef cleanup, 2 remove OPENSSL_NO_SETVBUF_IONBF Use setbuf(fp, NULL) instead of setvbuf(). This removes some ifdef complexity because all of our platforms support setbuf. Reviewed-by: Richard Levitte --- CHANGES | 1 + apps/apps.c | 18 +++--------------- apps/enc.c | 8 ++------ crypto/rand/randfile.c | 4 +--- makevms.com | 8 -------- 5 files changed, 7 insertions(+), 32 deletions(-) diff --git a/CHANGES b/CHANGES index 946d2a0362..2cecbf6010 100644 --- a/CHANGES +++ b/CHANGES @@ -43,6 +43,7 @@ *) Start cleaning up OPENSSL_NO_xxx #define's OPENSSL_NO_RIPEMD160, OPENSSL_NO_RIPEMD merged into OPENSSL_NO_RMD160 OPENSSL_NO_FP_API merged into OPENSSL_NO_STDIO + Use setbuf() and remove OPENSSL_NO_SETVBUF_IONBF [Rich Salz] *) Experimental support for a new, fast, unbiased prime candidate generator, diff --git a/apps/apps.c b/apps/apps.c index b6549d5040..ccd218260d 100644 --- a/apps/apps.c +++ b/apps/apps.c @@ -852,11 +852,7 @@ X509 *load_cert(BIO *err, const char *file, int format, } if (file == NULL) { -#ifdef _IONBF -# ifndef OPENSSL_NO_SETVBUF_IONBF - setvbuf(stdin, NULL, _IONBF, 0); -# endif /* ndef OPENSSL_NO_SETVBUF_IONBF */ -#endif + setbuf(stdin, NULL); /* don't do buffered reads */ BIO_set_fp(cert, stdin, BIO_NOCLOSE); } else { if (BIO_read_filename(cert, file) <= 0) { @@ -980,11 +976,7 @@ EVP_PKEY *load_key(BIO *err, const char *file, int format, int maybe_stdin, goto end; } if (file == NULL && maybe_stdin) { -#ifdef _IONBF -# ifndef OPENSSL_NO_SETVBUF_IONBF - setvbuf(stdin, NULL, _IONBF, 0); -# endif /* ndef OPENSSL_NO_SETVBUF_IONBF */ -#endif + setbuf(stdin, NULL); /* don't do buffered reads */ BIO_set_fp(key, stdin, BIO_NOCLOSE); } else if (BIO_read_filename(key, file) <= 0) { BIO_printf(err, "Error opening %s %s\n", key_descrip, file); @@ -1058,11 +1050,7 @@ EVP_PKEY *load_pubkey(BIO *err, const char *file, int format, int maybe_stdin, goto end; } if (file == NULL && maybe_stdin) { -#ifdef _IONBF -# ifndef OPENSSL_NO_SETVBUF_IONBF - setvbuf(stdin, NULL, _IONBF, 0); -# endif /* ndef OPENSSL_NO_SETVBUF_IONBF */ -#endif + setbuf(stdin, NULL); /* don't do buffered reads */ BIO_set_fp(key, stdin, BIO_NOCLOSE); } else if (BIO_read_filename(key, file) <= 0) { BIO_printf(err, "Error opening %s %s\n", key_descrip, file); diff --git a/apps/enc.c b/apps/enc.c index 8334f39284..3bf4a6eb04 100644 --- a/apps/enc.c +++ b/apps/enc.c @@ -396,10 +396,8 @@ int MAIN(int argc, char **argv) } if (inf == NULL) { -#ifndef OPENSSL_NO_SETVBUF_IONBF if (bufsize != NULL) - setvbuf(stdin, (char *)NULL, _IONBF, 0); -#endif /* ndef OPENSSL_NO_SETVBUF_IONBF */ + setbuf(stdin, NULL); BIO_set_fp(in, stdin, BIO_NOCLOSE); } else { if (BIO_read_filename(in, inf) <= 0) { @@ -442,10 +440,8 @@ int MAIN(int argc, char **argv) if (outf == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); -#ifndef OPENSSL_NO_SETVBUF_IONBF if (bufsize != NULL) - setvbuf(stdout, (char *)NULL, _IONBF, 0); -#endif /* ndef OPENSSL_NO_SETVBUF_IONBF */ + setbuf(stdin, NULL); /* don't do buffered reads */ #ifdef OPENSSL_SYS_VMS { BIO *tmpbio = BIO_new(BIO_f_linebuffer()); diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c index bec7058525..b234be0df5 100644 --- a/crypto/rand/randfile.c +++ b/crypto/rand/randfile.c @@ -160,9 +160,7 @@ int RAND_load_file(const char *file, long bytes) * because we will waste system entropy. */ bytes = (bytes == -1) ? 2048 : bytes; /* ok, is 2048 enough? */ -# ifndef OPENSSL_NO_SETVBUF_IONBF - setvbuf(in, NULL, _IONBF, 0); /* don't do buffered reads */ -# endif /* ndef OPENSSL_NO_SETVBUF_IONBF */ + setbuf(stdin, NULL); /* don't do buffered reads */ } #endif for (;;) { diff --git a/makevms.com b/makevms.com index 37e1e3ce18..82aa4ceea8 100755 --- a/makevms.com +++ b/makevms.com @@ -493,14 +493,6 @@ $ GOTO CONFIG_LOG_LOOP2 $ CONFIG_LOG_LOOP2_END: $! $ WRITE H_FILE "" -$ WRITE H_FILE "/* 2011-02-23 SMS." -$ WRITE H_FILE " * On VMS (V8.3), setvbuf() doesn't support a 64-bit" -$ WRITE H_FILE " * ""in"" pointer, and the help says:" -$ WRITE H_FILE " * Please note that the previously documented" -$ WRITE H_FILE " * value _IONBF is not supported." -$ WRITE H_FILE " * So, skip it on VMS." -$ WRITE H_FILE " */" -$ WRITE H_FILE "#define OPENSSL_NO_SETVBUF_IONBF" $ WRITE H_FILE "/* STCP support comes with TCPIP 5.7 ECO 2 " $ WRITE H_FILE " * enable on newer systems / 2012-02-24 arpadffy */" $ WRITE H_FILE "#define OPENSSL_NO_SCTP" -- 2.40.0