From d5f9166bacfb3757dfd6117310ad54ab749b11f9 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Fri, 4 Feb 2022 15:13:01 +0100 Subject: Move e_os.h to include/internal Including e_os.h with a path from a header file doesn't work well on certain exotic platform. It simply fails to build. Since we don't seem to be able to stop ourselves, the better move is to move e_os.h to an include directory that's part of the inclusion path given to the compiler. Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/17641) --- apps/include/apps.h | 2 +- apps/s_client.c | 2 +- crypto/asn1/ameth_lib.c | 2 +- crypto/asn1/asn1_gen.c | 2 +- crypto/bio/bio_local.h | 2 +- crypto/bio/bss_bio.c | 2 +- crypto/cmp/cmp_client.c | 2 +- crypto/conf/conf_api.c | 2 +- crypto/conf/conf_def.c | 2 +- crypto/conf/conf_lib.c | 2 +- crypto/core_namemap.c | 2 +- crypto/cpuid.c | 2 +- crypto/cryptlib.c | 2 +- crypto/des/cfb_enc.c | 2 +- crypto/dh/dh_group_params.c | 2 +- crypto/dh/dh_kdf.c | 4 +- crypto/dllmain.c | 2 +- crypto/dso/dso_dlfcn.c | 2 +- crypto/dso/dso_win32.c | 2 +- crypto/ec/curve448/arch_32/f_impl32.c | 2 +- crypto/ec/curve448/arch_64/f_impl64.c | 2 +- crypto/ec/ec_backend.c | 2 +- crypto/ec/ec_lib.c | 2 +- crypto/encode_decode/decoder_lib.c | 2 +- crypto/encode_decode/decoder_pkey.c | 2 +- crypto/encode_decode/encoder_lib.c | 2 +- crypto/encode_decode/encoder_pkey.c | 2 +- crypto/engine/eng_init.c | 2 +- crypto/engine/eng_lib.c | 2 +- crypto/engine/tb_asnmth.c | 2 +- crypto/err/err.c | 2 +- crypto/evp/ctrl_params_translate.c | 2 +- crypto/evp/ec_support.c | 2 +- crypto/evp/evp_lib.c | 2 +- crypto/evp/p_lib.c | 2 +- crypto/ffc/ffc_dh.c | 2 +- crypto/ffc/ffc_params.c | 2 +- crypto/getenv.c | 2 +- crypto/http/http_client.c | 2 +- crypto/info.c | 2 +- crypto/init.c | 2 +- crypto/mem.c | 2 +- crypto/mem_sec.c | 2 +- crypto/o_dir.c | 2 +- crypto/o_fopen.c | 2 +- crypto/o_init.c | 2 +- crypto/o_str.c | 2 +- crypto/objects/o_names.c | 2 +- crypto/params_dup.c | 2 +- crypto/property/property_parse.c | 2 +- crypto/rand/rand_deprecated.c | 2 +- crypto/rand/rand_lib.c | 2 +- crypto/rsa/rsa_backend.c | 2 +- crypto/store/store_lib.c | 2 +- crypto/store/store_result.c | 2 +- crypto/trace.c | 2 +- crypto/ts/ts_rsp_sign.c | 2 +- crypto/ui/ui_openssl.c | 2 +- crypto/x509/by_dir.c | 2 +- crypto/x509/v3_tlsf.c | 2 +- crypto/x509/v3_utl.c | 2 +- e_os.h | 414 --------------------- engines/e_devcrypto.c | 2 +- engines/e_loader_attic.c | 2 +- include/internal/common.h | 2 +- include/internal/e_os.h | 414 +++++++++++++++++++++ providers/common/capabilities.c | 2 +- providers/fips/self_test.c | 2 +- providers/implementations/ciphers/cipher_cts.c | 2 +- providers/implementations/kdfs/hkdf.c | 2 +- providers/implementations/kdfs/kbkdf.c | 2 +- providers/implementations/kdfs/tls1_prf.c | 2 +- providers/implementations/kdfs/x942kdf.c | 2 +- providers/implementations/kem/rsa_kem.c | 2 +- providers/implementations/keymgmt/dsa_kmgmt.c | 2 +- providers/implementations/keymgmt/ec_kmgmt.c | 2 +- providers/implementations/keymgmt/ecx_kmgmt.c | 2 +- .../implementations/keymgmt/mac_legacy_kmgmt.c | 2 +- providers/implementations/rands/drbg_ctr.c | 2 +- .../implementations/rands/seeding/rand_unix.c | 2 +- providers/implementations/rands/seeding/rand_vms.c | 2 +- providers/implementations/signature/rsa_sig.c | 2 +- providers/implementations/storemgmt/file_store.c | 2 +- ssl/d1_lib.c | 2 +- ssl/ssl_init.c | 2 +- ssl/ssl_lib.c | 2 +- ssl/ssl_local.h | 2 +- test/evp_extra_test.c | 2 +- test/evp_libctx_test.c | 2 +- test/evp_test.c | 2 +- test/helpers/ssltestlib.c | 2 +- test/p_test.c | 2 +- test/secmemtest.c | 2 +- test/ssl_old_test.c | 2 +- 94 files changed, 507 insertions(+), 507 deletions(-) delete mode 100644 e_os.h create mode 100644 include/internal/e_os.h diff --git a/apps/include/apps.h b/apps/include/apps.h index b6dbe74fa9..28c2bbdad2 100644 --- a/apps/include/apps.h +++ b/apps/include/apps.h @@ -10,7 +10,7 @@ #ifndef OSSL_APPS_H # define OSSL_APPS_H -# include "e_os.h" /* struct timeval for DTLS */ +# include "internal/e_os.h" /* struct timeval for DTLS */ # include "internal/common.h" /* for HAS_PREFIX */ # include "internal/nelem.h" # include "internal/sockets.h" /* for openssl_fdset() */ diff --git a/apps/s_client.c b/apps/s_client.c index 1d73e1b39e..06a58a8b51 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -8,7 +8,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include #include #include diff --git a/crypto/asn1/ameth_lib.c b/crypto/asn1/ameth_lib.c index 031a6c936a..9704492607 100644 --- a/crypto/asn1/ameth_lib.c +++ b/crypto/asn1/ameth_lib.c @@ -10,7 +10,7 @@ /* We need to use some engine deprecated APIs */ #define OPENSSL_SUPPRESS_DEPRECATED -#include "e_os.h" /* for strncasecmp */ +#include "internal/e_os.h" /* for strncasecmp */ #include "internal/cryptlib.h" #include #include diff --git a/crypto/asn1/asn1_gen.c b/crypto/asn1/asn1_gen.c index bb0dcb2e09..a112f7de9e 100644 --- a/crypto/asn1/asn1_gen.c +++ b/crypto/asn1/asn1_gen.c @@ -10,7 +10,7 @@ #include "internal/cryptlib.h" #include #include -#include "e_os.h" /* strncasecmp() */ +#include "internal/e_os.h" /* strncasecmp() */ #define ASN1_GEN_FLAG 0x10000 #define ASN1_GEN_FLAG_IMP (ASN1_GEN_FLAG|1) diff --git a/crypto/bio/bio_local.h b/crypto/bio/bio_local.h index 749e8f810c..6ba0196ce6 100644 --- a/crypto/bio/bio_local.h +++ b/crypto/bio/bio_local.h @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include "internal/sockets.h" /* BEGIN BIO_ADDRINFO/BIO_ADDR stuff. */ diff --git a/crypto/bio/bss_bio.c b/crypto/bio/bss_bio.c index 92dd262309..aaac451314 100644 --- a/crypto/bio/bss_bio.c +++ b/crypto/bio/bss_bio.c @@ -15,7 +15,7 @@ * See ssl/ssltest.c for some hints on how this can be used. */ -#include "e_os.h" +#include "internal/e_os.h" #include #include #include diff --git a/crypto/cmp/cmp_client.c b/crypto/cmp/cmp_client.c index 4a7a87ff74..0ca7f94a86 100644 --- a/crypto/cmp/cmp_client.c +++ b/crypto/cmp/cmp_client.c @@ -11,7 +11,7 @@ #include "cmp_local.h" #include "internal/cryptlib.h" -#include "e_os.h" /* ossl_sleep() */ +#include "internal/e_os.h" /* ossl_sleep() */ /* explicit #includes not strictly needed since implied by the above: */ #include diff --git a/crypto/conf/conf_api.c b/crypto/conf/conf_api.c index 7a4efe6dbb..37e66af78e 100644 --- a/crypto/conf/conf_api.c +++ b/crypto/conf/conf_api.c @@ -9,7 +9,7 @@ /* Part of the code in here was originally in conf.c, which is now removed */ -#include "e_os.h" +#include "internal/e_os.h" #include "internal/cryptlib.h" #include #include diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c index 26764dad00..9d79a900c8 100644 --- a/crypto/conf/conf_def.c +++ b/crypto/conf/conf_def.c @@ -11,7 +11,7 @@ #include #include -#include "e_os.h" /* strcasecmp and struct stat */ +#include "internal/e_os.h" /* strcasecmp and struct stat */ #ifdef __TANDEM # include /* needed for stat.h */ # include /* struct stat */ diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c index a236003525..fe08e0af5f 100644 --- a/crypto/conf/conf_lib.c +++ b/crypto/conf/conf_lib.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include #include #include "internal/conf.h" diff --git a/crypto/core_namemap.c b/crypto/core_namemap.c index 6cb0ec5a06..f058e629f3 100644 --- a/crypto/core_namemap.c +++ b/crypto/core_namemap.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" /* strcasecmp */ +#include "internal/e_os.h" /* strcasecmp */ #include "internal/namemap.h" #include #include "crypto/lhash.h" /* ossl_lh_strcasehash */ diff --git a/crypto/cpuid.c b/crypto/cpuid.c index 048689f410..75bd03bffe 100644 --- a/crypto/cpuid.c +++ b/crypto/cpuid.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include "crypto/cryptlib.h" #if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \ diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c index 6e73b8352c..f78c2236e4 100644 --- a/crypto/cryptlib.c +++ b/crypto/cryptlib.c @@ -8,7 +8,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include "crypto/cryptlib.h" #include diff --git a/crypto/des/cfb_enc.c b/crypto/des/cfb_enc.c index 30458d50a1..e8813755bf 100644 --- a/crypto/des/cfb_enc.c +++ b/crypto/des/cfb_enc.c @@ -13,7 +13,7 @@ */ #include "internal/deprecated.h" -#include "e_os.h" +#include "internal/e_os.h" #include "des_local.h" #include diff --git a/crypto/dh/dh_group_params.c b/crypto/dh/dh_group_params.c index c71f4053da..dec50caf66 100644 --- a/crypto/dh/dh_group_params.c +++ b/crypto/dh/dh_group_params.c @@ -23,7 +23,7 @@ #include #include "internal/nelem.h" #include "crypto/dh.h" -#include "e_os.h" /* strcasecmp */ +#include "internal/e_os.h" /* strcasecmp */ static DH *dh_param_init(OSSL_LIB_CTX *libctx, const DH_NAMED_GROUP *group) { diff --git a/crypto/dh/dh_kdf.c b/crypto/dh/dh_kdf.c index 419e7711d3..eda3d3998a 100644 --- a/crypto/dh/dh_kdf.c +++ b/crypto/dh/dh_kdf.c @@ -13,8 +13,8 @@ */ #include "internal/deprecated.h" -#include "e_os.h" -#include "e_os.h" +#include "internal/e_os.h" +#include "internal/e_os.h" #include #include #include diff --git a/crypto/dllmain.c b/crypto/dllmain.c index 48c0cd3122..65d9be6767 100644 --- a/crypto/dllmain.c +++ b/crypto/dllmain.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include "crypto/cryptlib.h" #if defined(_WIN32) || defined(__CYGWIN__) diff --git a/crypto/dso/dso_dlfcn.c b/crypto/dso/dso_dlfcn.c index 6a988cc727..982b117e70 100644 --- a/crypto/dso/dso_dlfcn.c +++ b/crypto/dso/dso_dlfcn.c @@ -17,7 +17,7 @@ #endif #include "dso_local.h" -#include "e_os.h" +#include "internal/e_os.h" #ifdef DSO_DLFCN diff --git a/crypto/dso/dso_win32.c b/crypto/dso/dso_win32.c index 4d3059d438..08ad8f46b3 100644 --- a/crypto/dso/dso_win32.c +++ b/crypto/dso/dso_win32.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include "dso_local.h" #if defined(DSO_WIN32) diff --git a/crypto/ec/curve448/arch_32/f_impl32.c b/crypto/ec/curve448/arch_32/f_impl32.c index 8714a51422..45d5587347 100644 --- a/crypto/ec/curve448/arch_32/f_impl32.c +++ b/crypto/ec/curve448/arch_32/f_impl32.c @@ -10,7 +10,7 @@ * Originally written by Mike Hamburg */ -#include "e_os.h" +#include "internal/e_os.h" #include #include "internal/numbers.h" diff --git a/crypto/ec/curve448/arch_64/f_impl64.c b/crypto/ec/curve448/arch_64/f_impl64.c index 8f7a7dd391..10a9b065e5 100644 --- a/crypto/ec/curve448/arch_64/f_impl64.c +++ b/crypto/ec/curve448/arch_64/f_impl64.c @@ -10,7 +10,7 @@ * Originally written by Mike Hamburg */ -#include "e_os.h" +#include "internal/e_os.h" #include #include "internal/numbers.h" diff --git a/crypto/ec/ec_backend.c b/crypto/ec/ec_backend.c index 2db1c1380e..d2fff0657d 100644 --- a/crypto/ec/ec_backend.c +++ b/crypto/ec/ec_backend.c @@ -24,7 +24,7 @@ #include "crypto/bn.h" #include "crypto/ec.h" #include "ec_local.h" -#include "e_os.h" +#include "internal/e_os.h" #include "internal/param_build_set.h" /* Mapping between a flag and a name */ diff --git a/crypto/ec/ec_lib.c b/crypto/ec/ec_lib.c index 2d85d4f23a..2aeab7e3b6 100644 --- a/crypto/ec/ec_lib.c +++ b/crypto/ec/ec_lib.c @@ -22,7 +22,7 @@ #include "crypto/ec.h" #include "internal/nelem.h" #include "ec_local.h" -#include "e_os.h" /* strcasecmp */ +#include "internal/e_os.h" /* strcasecmp */ /* functions for EC_GROUP objects */ diff --git a/crypto/encode_decode/decoder_lib.c b/crypto/encode_decode/decoder_lib.c index 10a38b6f82..9242cd2c6f 100644 --- a/crypto/encode_decode/decoder_lib.c +++ b/crypto/encode_decode/decoder_lib.c @@ -20,7 +20,7 @@ #include "internal/provider.h" #include "crypto/decoder.h" #include "encoder_local.h" -#include "e_os.h" +#include "internal/e_os.h" struct decoder_process_data_st { OSSL_DECODER_CTX *ctx; diff --git a/crypto/encode_decode/decoder_pkey.c b/crypto/encode_decode/decoder_pkey.c index 475117a463..472abef311 100644 --- a/crypto/encode_decode/decoder_pkey.c +++ b/crypto/encode_decode/decoder_pkey.c @@ -18,7 +18,7 @@ #include "crypto/evp.h" #include "crypto/decoder.h" #include "encoder_local.h" -#include "e_os.h" /* strcasecmp on Windows */ +#include "internal/e_os.h" /* strcasecmp on Windows */ int OSSL_DECODER_CTX_set_passphrase(OSSL_DECODER_CTX *ctx, const unsigned char *kstr, diff --git a/crypto/encode_decode/encoder_lib.c b/crypto/encode_decode/encoder_lib.c index 8d083bd6a6..52cc404097 100644 --- a/crypto/encode_decode/encoder_lib.c +++ b/crypto/encode_decode/encoder_lib.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" /* strcasecmp on Windows */ +#include "internal/e_os.h" /* strcasecmp on Windows */ #include #include #include diff --git a/crypto/encode_decode/encoder_pkey.c b/crypto/encode_decode/encoder_pkey.c index 109dfa80cd..ba29da6385 100644 --- a/crypto/encode_decode/encoder_pkey.c +++ b/crypto/encode_decode/encoder_pkey.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" /* strcasecmp on Windows */ +#include "internal/e_os.h" /* strcasecmp on Windows */ #include #include #include diff --git a/crypto/engine/eng_init.c b/crypto/engine/eng_init.c index c204eb1899..343a069fa0 100644 --- a/crypto/engine/eng_init.c +++ b/crypto/engine/eng_init.c @@ -10,7 +10,7 @@ /* We need to use some engine deprecated APIs */ #define OPENSSL_SUPPRESS_DEPRECATED -#include "e_os.h" +#include "internal/e_os.h" #include "eng_local.h" /* diff --git a/crypto/engine/eng_lib.c b/crypto/engine/eng_lib.c index 05c6a67c1e..813bcd6df6 100644 --- a/crypto/engine/eng_lib.c +++ b/crypto/engine/eng_lib.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include "eng_local.h" #include #include "internal/refcount.h" diff --git a/crypto/engine/tb_asnmth.c b/crypto/engine/tb_asnmth.c index e3a5c82e99..bf424ff09e 100644 --- a/crypto/engine/tb_asnmth.c +++ b/crypto/engine/tb_asnmth.c @@ -10,7 +10,7 @@ /* We need to use some engine deprecated APIs */ #define OPENSSL_SUPPRESS_DEPRECATED -#include "e_os.h" +#include "internal/e_os.h" #include "eng_local.h" #include #include "crypto/asn1.h" diff --git a/crypto/err/err.c b/crypto/err/err.c index 63cf682382..04eaf43b72 100644 --- a/crypto/err/err.c +++ b/crypto/err/err.c @@ -23,7 +23,7 @@ #include "internal/thread_once.h" #include "crypto/ctype.h" #include "internal/constant_time.h" -#include "e_os.h" +#include "internal/e_os.h" #include "err_local.h" /* Forward declaration in case it's not published because of configuration */ diff --git a/crypto/evp/ctrl_params_translate.c b/crypto/evp/ctrl_params_translate.c index 2deb1d9b47..33e5e7f189 100644 --- a/crypto/evp/ctrl_params_translate.c +++ b/crypto/evp/ctrl_params_translate.c @@ -37,7 +37,7 @@ #include "crypto/dh.h" #include "crypto/ec.h" -#include "e_os.h" /* strcasecmp() for Windows */ +#include "internal/e_os.h" /* strcasecmp() for Windows */ struct translation_ctx_st; /* Forwarding */ struct translation_st; /* Forwarding */ diff --git a/crypto/evp/ec_support.c b/crypto/evp/ec_support.c index 8550be65e7..979e861cff 100644 --- a/crypto/evp/ec_support.c +++ b/crypto/evp/ec_support.c @@ -10,7 +10,7 @@ #include #include #include "crypto/ec.h" -#include "e_os.h" /* strcasecmp required by windows */ +#include "internal/e_os.h" /* strcasecmp required by windows */ typedef struct ec_name2nid_st { const char *name; diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c index 24092cfd5b..3d261c282f 100644 --- a/crypto/evp/evp_lib.c +++ b/crypto/evp/evp_lib.c @@ -15,7 +15,7 @@ #include #include -#include "e_os.h" /* strcasecmp */ +#include "internal/e_os.h" /* strcasecmp */ #include "internal/cryptlib.h" #include #include diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index 27138af564..be15f105b7 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -50,7 +50,7 @@ #include "internal/provider.h" #include "evp_local.h" -#include "e_os.h" /* strcasecmp on Windows */ +#include "internal/e_os.h" /* strcasecmp on Windows */ static int pkey_set_type(EVP_PKEY *pkey, ENGINE *e, int type, const char *str, int len, EVP_KEYMGMT *keymgmt); diff --git a/crypto/ffc/ffc_dh.c b/crypto/ffc/ffc_dh.c index e9f597c46c..cedf283533 100644 --- a/crypto/ffc/ffc_dh.c +++ b/crypto/ffc/ffc_dh.c @@ -10,7 +10,7 @@ #include "internal/ffc.h" #include "internal/nelem.h" #include "crypto/bn_dh.h" -#include "e_os.h" /* strcasecmp */ +#include "internal/e_os.h" /* strcasecmp */ #ifndef OPENSSL_NO_DH diff --git a/crypto/ffc/ffc_params.c b/crypto/ffc/ffc_params.c index 6e025a06be..1078a7b845 100644 --- a/crypto/ffc/ffc_params.c +++ b/crypto/ffc/ffc_params.c @@ -12,7 +12,7 @@ #include "internal/ffc.h" #include "internal/param_build_set.h" #include "internal/nelem.h" -#include "e_os.h" /* strcasecmp */ +#include "internal/e_os.h" /* strcasecmp */ #ifndef FIPS_MODULE # include /* ossl_ffc_params_print */ diff --git a/crypto/getenv.c b/crypto/getenv.c index e79b6cc161..b263d1b624 100644 --- a/crypto/getenv.c +++ b/crypto/getenv.c @@ -13,7 +13,7 @@ #include #include "internal/cryptlib.h" -#include "e_os.h" +#include "internal/e_os.h" char *ossl_safe_getenv(const char *name) { diff --git a/crypto/http/http_client.c b/crypto/http/http_client.c index 14c2cbf2b5..d6345b4582 100644 --- a/crypto/http/http_client.c +++ b/crypto/http/http_client.c @@ -8,7 +8,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include #include #include "crypto/ctype.h" diff --git a/crypto/info.c b/crypto/info.c index f3bef56b13..05edbc3fc8 100644 --- a/crypto/info.c +++ b/crypto/info.c @@ -12,7 +12,7 @@ #include "crypto/dso_conf.h" #include "internal/thread_once.h" #include "internal/cryptlib.h" -#include "e_os.h" +#include "internal/e_os.h" #include "buildinf.h" #if defined(__arm__) || defined(__arm) || defined(__aarch64__) diff --git a/crypto/init.c b/crypto/init.c index 6a27d1a8e4..b7d7ad0ea3 100644 --- a/crypto/init.c +++ b/crypto/init.c @@ -10,7 +10,7 @@ /* We need to use some engine deprecated APIs */ #define OPENSSL_SUPPRESS_DEPRECATED -#include "e_os.h" +#include "internal/e_os.h" #include "crypto/cryptlib.h" #include #include "crypto/rand.h" diff --git a/crypto/mem.c b/crypto/mem.c index 242d88470a..f76c48d886 100644 --- a/crypto/mem.c +++ b/crypto/mem.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include "internal/cryptlib.h" #include "crypto/cryptlib.h" #include diff --git a/crypto/mem_sec.c b/crypto/mem_sec.c index c2cc2cbf32..4806102805 100644 --- a/crypto/mem_sec.c +++ b/crypto/mem_sec.c @@ -15,7 +15,7 @@ * For details on that implementation, see below (look for uppercase * "SECURE HEAP IMPLEMENTATION"). */ -#include "e_os.h" +#include "internal/e_os.h" #include #include diff --git a/crypto/o_dir.c b/crypto/o_dir.c index 6857a2e17d..8772347930 100644 --- a/crypto/o_dir.c +++ b/crypto/o_dir.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include /* diff --git a/crypto/o_fopen.c b/crypto/o_fopen.c index 8095fffbe0..f449c3ec1d 100644 --- a/crypto/o_fopen.c +++ b/crypto/o_fopen.c @@ -25,7 +25,7 @@ # endif # endif -#include "e_os.h" +#include "internal/e_os.h" #include "internal/cryptlib.h" #if !defined(OPENSSL_NO_STDIO) diff --git a/crypto/o_init.c b/crypto/o_init.c index a0b4256f78..30c19b81e8 100644 --- a/crypto/o_init.c +++ b/crypto/o_init.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include /* diff --git a/crypto/o_str.c b/crypto/o_str.c index d7aa665ad8..649a669d25 100644 --- a/crypto/o_str.c +++ b/crypto/o_str.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include #include #include "internal/cryptlib.h" diff --git a/crypto/objects/o_names.c b/crypto/objects/o_names.c index 92152eeb66..82fbc3bf96 100644 --- a/crypto/objects/o_names.c +++ b/crypto/objects/o_names.c @@ -19,7 +19,7 @@ #include "internal/thread_once.h" #include "crypto/lhash.h" #include "obj_local.h" -#include "e_os.h" +#include "internal/e_os.h" /* * We define this wrapper for two reasons. Firstly, later versions of diff --git a/crypto/params_dup.c b/crypto/params_dup.c index 530bc530cc..3c3b18e620 100644 --- a/crypto/params_dup.c +++ b/crypto/params_dup.c @@ -11,7 +11,7 @@ #include #include #include "internal/param_build_set.h" -#include "e_os.h" /* strcasecmp */ +#include "internal/e_os.h" /* strcasecmp */ #define OSSL_PARAM_ALLOCATED_END 127 #define OSSL_PARAM_MERGE_LIST_MAX 128 diff --git a/crypto/property/property_parse.c b/crypto/property/property_parse.c index dc35646be2..4b99ee1f39 100644 --- a/crypto/property/property_parse.c +++ b/crypto/property/property_parse.c @@ -17,7 +17,7 @@ #include "crypto/ctype.h" #include "internal/nelem.h" #include "property_local.h" -#include "e_os.h" +#include "internal/e_os.h" DEFINE_STACK_OF(OSSL_PROPERTY_DEFINITION) diff --git a/crypto/rand/rand_deprecated.c b/crypto/rand/rand_deprecated.c index dd69f1beb7..a6bc2a99e3 100644 --- a/crypto/rand/rand_deprecated.c +++ b/crypto/rand/rand_deprecated.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include +#include "internal/e_os.h" #include #include diff --git a/crypto/rand/rand_lib.c b/crypto/rand/rand_lib.c index 30b6cb817f..4f36e84bd4 100644 --- a/crypto/rand/rand_lib.c +++ b/crypto/rand/rand_lib.c @@ -28,7 +28,7 @@ # include # include "crypto/rand_pool.h" # include "prov/seeding.h" -# include "e_os.h" +# include "internal/e_os.h" # ifndef OPENSSL_NO_ENGINE /* non-NULL if default_RAND_meth is ENGINE-provided */ diff --git a/crypto/rsa/rsa_backend.c b/crypto/rsa/rsa_backend.c index 4385dd0135..a0e1e14e4d 100644 --- a/crypto/rsa/rsa_backend.c +++ b/crypto/rsa/rsa_backend.c @@ -27,7 +27,7 @@ #include "crypto/rsa.h" #include "rsa_local.h" -#include "e_os.h" /* strcasecmp for Windows() */ +#include "internal/e_os.h" /* strcasecmp for Windows() */ /* * The intention with the "backend" source file is to offer backend support diff --git a/crypto/store/store_lib.c b/crypto/store/store_lib.c index 4efa7eea03..81e0f70a19 100644 --- a/crypto/store/store_lib.c +++ b/crypto/store/store_lib.c @@ -14,7 +14,7 @@ /* We need to use some STORE deprecated APIs */ #define OPENSSL_SUPPRESS_DEPRECATED -#include "e_os.h" +#include "internal/e_os.h" #include #include diff --git a/crypto/store/store_result.c b/crypto/store/store_result.c index de00f4f562..567b9c99cd 100644 --- a/crypto/store/store_result.c +++ b/crypto/store/store_result.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include #include diff --git a/crypto/trace.c b/crypto/trace.c index dc194acb52..a9a097f1a3 100644 --- a/crypto/trace.c +++ b/crypto/trace.c @@ -19,7 +19,7 @@ #include "internal/refcount.h" #include "crypto/cryptlib.h" -#include "e_os.h" /* strcasecmp for Windows */ +#include "internal/e_os.h" /* strcasecmp for Windows */ #ifndef OPENSSL_NO_TRACE diff --git a/crypto/ts/ts_rsp_sign.c b/crypto/ts/ts_rsp_sign.c index cf3e5443de..99b2228a06 100644 --- a/crypto/ts/ts_rsp_sign.c +++ b/crypto/ts/ts_rsp_sign.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include #include diff --git a/crypto/ui/ui_openssl.c b/crypto/ui/ui_openssl.c index 37b98910c7..fc5b12b03d 100644 --- a/crypto/ui/ui_openssl.c +++ b/crypto/ui/ui_openssl.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include #include #include diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c index 258ad51852..599d5463bb 100644 --- a/crypto/x509/by_dir.c +++ b/crypto/x509/by_dir.c @@ -16,7 +16,7 @@ # include #endif -#include "e_os.h" +#include "internal/e_os.h" #include "internal/cryptlib.h" #include #include diff --git a/crypto/x509/v3_tlsf.c b/crypto/x509/v3_tlsf.c index 6a613d64e6..32ac300355 100644 --- a/crypto/x509/v3_tlsf.c +++ b/crypto/x509/v3_tlsf.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include "internal/cryptlib.h" #include #include diff --git a/crypto/x509/v3_utl.c b/crypto/x509/v3_utl.c index 72d4d3867d..0687ffabc9 100644 --- a/crypto/x509/v3_utl.c +++ b/crypto/x509/v3_utl.c @@ -9,7 +9,7 @@ /* X509 v3 extension utilities */ -#include "e_os.h" +#include "internal/e_os.h" #include "internal/cryptlib.h" #include #include diff --git a/e_os.h b/e_os.h deleted file mode 100644 index e1608ae55d..0000000000 --- a/e_os.h +++ /dev/null @@ -1,414 +0,0 @@ -/* - * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the Apache License 2.0 (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef OSSL_E_OS_H -# define OSSL_E_OS_H - -# include -# include - -# include -# include -# include "internal/nelem.h" - -/* - * contains what we can justify to make visible to the - * outside; this file e_os.h is not part of the exported interface. - */ - -# if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI) -# define NO_CHMOD -# define NO_SYSLOG -# endif - -# define get_last_sys_error() errno -# define clear_sys_error() errno=0 -# define set_sys_error(e) errno=(e) - -/******************************************************************** - The Microsoft section - ********************************************************************/ -# if defined(OPENSSL_SYS_WIN32) && !defined(WIN32) -# define WIN32 -# endif -# if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -# endif -# if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS) -# define MSDOS -# endif - -# ifdef WIN32 -# undef get_last_sys_error -# undef clear_sys_error -# undef set_sys_error -# define get_last_sys_error() GetLastError() -# define clear_sys_error() SetLastError(0) -# define set_sys_error(e) SetLastError(e) -# if !defined(WINNT) -# define WIN_CONSOLE_BUG -# endif -# else -# endif - -# if (defined(WINDOWS) || defined(MSDOS)) - -# ifdef __DJGPP__ -# include -# include -# define _setmode setmode -# define _O_TEXT O_TEXT -# define _O_BINARY O_BINARY -# undef DEVRANDOM_EGD /* Neither MS-DOS nor FreeDOS provide 'egd' sockets. */ -# undef DEVRANDOM -# define DEVRANDOM "/dev/urandom\x24" -# endif /* __DJGPP__ */ - -# ifndef S_IFDIR -# define S_IFDIR _S_IFDIR -# endif - -# ifndef S_IFMT -# define S_IFMT _S_IFMT -# endif - -# if !defined(WINNT) && !defined(__DJGPP__) -# define NO_SYSLOG -# endif - -# ifdef WINDOWS -# if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT) - /* - * Defining _WIN32_WINNT here in e_os.h implies certain "discipline." - * Most notably we ought to check for availability of each specific - * routine that was introduced after denoted _WIN32_WINNT with - * GetProcAddress(). Normally newer functions are masked with higher - * _WIN32_WINNT in SDK headers. So that if you wish to use them in - * some module, you'd need to override _WIN32_WINNT definition in - * the target module in order to "reach for" prototypes, but replace - * calls to new functions with indirect calls. Alternatively it - * might be possible to achieve the goal by /DELAYLOAD-ing .DLLs - * and check for current OS version instead. - */ -# define _WIN32_WINNT 0x0501 -# endif -# if defined(_WIN32_WINNT) || defined(_WIN32_WCE) - /* - * Just like defining _WIN32_WINNT including winsock2.h implies - * certain "discipline" for maintaining [broad] binary compatibility. - * As long as structures are invariant among Winsock versions, - * it's sufficient to check for specific Winsock2 API availability - * at run-time [DSO_global_lookup is recommended]... - */ -# include -# include - /* - * Clang-based C++Builder 10.3.3 toolchains cannot find C inline - * definitions at link-time. This header defines WspiapiLoad() as an - * __inline function. https://quality.embarcadero.com/browse/RSP-33806 - */ -# if !defined(__BORLANDC__) || !defined(__clang__) -# include -# endif - /* yes, they have to be #included prior to */ -# endif -# include -# include -# include -# include -# if defined(_WIN32_WCE) && !defined(EACCES) -# define EACCES 13 -# endif -# include -# ifdef _WIN64 -# define strlen(s) _strlen31(s) -/* cut strings to 2GB */ -static __inline unsigned int _strlen31(const char *str) -{ - unsigned int len = 0; - while (*str && len < 0x80000000U) - str++, len++; - return len & 0x7FFFFFFF; -} -# endif -# include -# if defined(_MSC_VER) && !defined(_WIN32_WCE) && !defined(_DLL) && defined(stdin) -# if _MSC_VER>=1300 && _MSC_VER<1600 -# undef stdin -# undef stdout -# undef stderr -FILE *__iob_func(); -# define stdin (&__iob_func()[0]) -# define stdout (&__iob_func()[1]) -# define stderr (&__iob_func()[2]) -# endif -# endif -# endif -# include -# include - -# ifdef OPENSSL_SYS_WINCE -# define OPENSSL_NO_POSIX_IO -# endif - -# define EXIT(n) exit(n) -# define LIST_SEPARATOR_CHAR ';' -# ifndef W_OK -# define W_OK 2 -# endif -# ifndef R_OK -# define R_OK 4 -# endif -# ifdef OPENSSL_SYS_WINCE -# define DEFAULT_HOME "" -# else -# define DEFAULT_HOME "C:" -# endif - -/* Avoid Visual Studio 13 GetVersion deprecated problems */ -# if defined(_MSC_VER) && _MSC_VER>=1800 -# define check_winnt() (1) -# define check_win_minplat(x) (1) -# else -# define check_winnt() (GetVersion() < 0x80000000) -# define check_win_minplat(x) (LOBYTE(LOWORD(GetVersion())) >= (x)) -# endif - -# else /* The non-microsoft world */ - -# if defined(OPENSSL_SYS_VXWORKS) -# include -# else -# include -# endif - -# ifdef OPENSSL_SYS_VMS -# define VMS 1 - /* - * some programs don't include stdlib, so exit() and others give implicit - * function warnings - */ -# include -# if defined(__DECC) -# include -# else -# include -# endif -# define LIST_SEPARATOR_CHAR ',' - /* We don't have any well-defined random devices on VMS, yet... */ -# undef DEVRANDOM - /*- - We need to do this since VMS has the following coding on status codes: - - Bits 0-2: status type: 0 = warning, 1 = success, 2 = error, 3 = info ... - The important thing to know is that odd numbers are considered - good, while even ones are considered errors. - Bits 3-15: actual status number - Bits 16-27: facility number. 0 is considered "unknown" - Bits 28-31: control bits. If bit 28 is set, the shell won't try to - output the message (which, for random codes, just looks ugly) - - So, what we do here is to change 0 to 1 to get the default success status, - and everything else is shifted up to fit into the status number field, and - the status is tagged as an error, which is what is wanted here. - - Finally, we add the VMS C facility code 0x35a000, because there are some - programs, such as Perl, that will reinterpret the code back to something - POSIX. 'man perlvms' explains it further. - - NOTE: the perlvms manual wants to turn all codes 2 to 255 into success - codes (status type = 1). I couldn't disagree more. Fortunately, the - status type doesn't seem to bother Perl. - -- Richard Levitte - */ -# define EXIT(n) exit((n) ? (((n) << 3) | 2 | 0x10000000 | 0x35a000) : 1) - -# define DEFAULT_HOME "SYS$LOGIN:" - -# else - /* !defined VMS */ -# include -# include -# ifdef OPENSSL_SYS_WIN32_CYGWIN -# include -# include -# endif - -# define LIST_SEPARATOR_CHAR ':' -# define EXIT(n) exit(n) -# endif - -# endif - -/***********************************************/ - -# if defined(OPENSSL_SYS_WINDOWS) -# define strcasecmp _stricmp -# define strncasecmp _strnicmp -# if (_MSC_VER >= 1310) && !defined(_WIN32_WCE) -# define open _open -# define fdopen _fdopen -# define close _close -# ifndef strdup -# define strdup _strdup -# endif -# define unlink _unlink -# define fileno _fileno -# endif -# else -# include -# endif - -/* vxworks */ -# if defined(OPENSSL_SYS_VXWORKS) -# include -# include -# include -# include -# include -# include - -# define TTY_STRUCT int -# define sleep(a) taskDelay((a) * sysClkRateGet()) - -/* - * NOTE: these are implemented by helpers in database app! if the database is - * not linked, we need to implement them elsewhere - */ -struct hostent *gethostbyname(const char *name); -struct hostent *gethostbyaddr(const char *addr, int length, int type); -struct servent *getservbyname(const char *name, const char *proto); - -# endif -/* end vxworks */ - -/* system-specific variants defining ossl_sleep() */ -#ifdef OPENSSL_SYS_UNIX -# include -static ossl_inline void ossl_sleep(unsigned long millis) -{ -# ifdef OPENSSL_SYS_VXWORKS - struct timespec ts; - ts.tv_sec = (long int) (millis / 1000); - ts.tv_nsec = (long int) (millis % 1000) * 1000000ul; - nanosleep(&ts, NULL); -# elif defined(__TANDEM) -# if !defined(_REENTRANT) -# include - /* HPNS does not support usleep for non threaded apps */ - PROCESS_DELAY_(millis * 1000); -# elif defined(_SPT_MODEL_) -# include -# include - usleep(millis * 1000); -# else - usleep(millis * 1000); -# endif -# else - usleep(millis * 1000); -# endif -} -#elif defined(_WIN32) -# include -static ossl_inline void ossl_sleep(unsigned long millis) -{ - Sleep(millis); -} -#else -/* Fallback to a busy wait */ -static ossl_inline void ossl_sleep(unsigned long millis) -{ - struct timeval start, now; - unsigned long elapsedms; - - gettimeofday(&start, NULL); - do { - gettimeofday(&now, NULL); - elapsedms = (((now.tv_sec - start.tv_sec) * 1000000) - + now.tv_usec - start.tv_usec) / 1000; - } while (elapsedms < millis); -} -#endif /* defined OPENSSL_SYS_UNIX */ - -/* ----------------------------- HP NonStop -------------------------------- */ -/* Required to support platform variant without getpid() and pid_t. */ -# if defined(__TANDEM) && defined(_GUARDIAN_TARGET) -# include -# include -# define getservbyname(name,proto) getservbyname((char*)name,proto) -# define gethostbyname(name) gethostbyname((char*)name) -# define ioctlsocket(a,b,c) ioctl(a,b,c) -# ifdef NO_GETPID -inline int nssgetpid(); -# ifndef NSSGETPID_MACRO -# define NSSGETPID_MACRO -# include -# include - inline int nssgetpid() - { - short phandle[10]={0}; - union pseudo_pid { - struct { - short cpu; - short pin; - } cpu_pin ; - int ppid; - } ppid = { 0 }; - PROCESSHANDLE_GETMINE_(phandle); - PROCESSHANDLE_DECOMPOSE_(phandle, &ppid.cpu_pin.cpu, &ppid.cpu_pin.pin); - return ppid.ppid; - } -# define getpid(a) nssgetpid(a) -# endif /* NSSGETPID_MACRO */ -# endif /* NO_GETPID */ -/*# define setsockopt(a,b,c,d,f) setsockopt(a,b,c,(char*)d,f)*/ -/*# define getsockopt(a,b,c,d,f) getsockopt(a,b,c,(char*)d,f)*/ -/*# define connect(a,b,c) connect(a,(struct sockaddr *)b,c)*/ -/*# define bind(a,b,c) bind(a,(struct sockaddr *)b,c)*/ -/*# define sendto(a,b,c,d,e,f) sendto(a,(char*)b,c,d,(struct sockaddr *)e,f)*/ -# if defined(OPENSSL_THREADS) && !defined(_PUT_MODEL_) - /* - * HPNS SPT threads - */ -# define SPT_THREAD_SIGNAL 1 -# define SPT_THREAD_AWARE 1 -# include -# undef close -# define close spt_close -/* -# define get_last_socket_error() errno -# define clear_socket_error() errno=0 -# define ioctlsocket(a,b,c) ioctl(a,b,c) -# define closesocket(s) close(s) -# define readsocket(s,b,n) read((s),(char*)(b),(n)) -# define writesocket(s,b,n) write((s),(char*)(b),(n) -*/ -# define accept(a,b,c) accept(a,(struct sockaddr *)b,c) -# define recvfrom(a,b,c,d,e,f) recvfrom(a,b,(socklen_t)c,d,e,f) -# endif -# endif - -# ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -# define CRYPTO_memcmp memcmp -# endif - -# ifndef OPENSSL_NO_SECURE_MEMORY - /* unistd.h defines _POSIX_VERSION */ -# if (defined(OPENSSL_SYS_UNIX) \ - && ( (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \ - || defined(__sun) || defined(__hpux) || defined(__sgi) \ - || defined(__osf__) )) \ - || defined(_WIN32) - /* secure memory is implemented */ -# else -# define OPENSSL_NO_SECURE_MEMORY -# endif -# endif - -#endif diff --git a/engines/e_devcrypto.c b/engines/e_devcrypto.c index adf53d8d91..abc2930fb0 100644 --- a/engines/e_devcrypto.c +++ b/engines/e_devcrypto.c @@ -10,7 +10,7 @@ /* We need to use some deprecated APIs */ #define OPENSSL_SUPPRESS_DEPRECATED -#include "../e_os.h" +#include "internal/e_os.h" #include #include #include diff --git a/engines/e_loader_attic.c b/engines/e_loader_attic.c index e2a5474c1c..be36c6e397 100644 --- a/engines/e_loader_attic.c +++ b/engines/e_loader_attic.c @@ -14,7 +14,7 @@ /* We need to use some engine deprecated APIs */ #define OPENSSL_SUPPRESS_DEPRECATED -#include "../e_os.h" /* for stat and strncasecmp */ +#include "internal/e_os.h" /* for stat and strncasecmp */ #include #include #include diff --git a/include/internal/common.h b/include/internal/common.h index 44224f3ba8..f20b041ac0 100644 --- a/include/internal/common.h +++ b/include/internal/common.h @@ -13,7 +13,7 @@ # include # include -# include "../../e_os.h" /* To get strncasecmp() on Windows */ +# include "internal/e_os.h" /* To get strncasecmp() on Windows */ # include "internal/nelem.h" diff --git a/include/internal/e_os.h b/include/internal/e_os.h new file mode 100644 index 0000000000..e1608ae55d --- /dev/null +++ b/include/internal/e_os.h @@ -0,0 +1,414 @@ +/* + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_E_OS_H +# define OSSL_E_OS_H + +# include +# include + +# include +# include +# include "internal/nelem.h" + +/* + * contains what we can justify to make visible to the + * outside; this file e_os.h is not part of the exported interface. + */ + +# if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI) +# define NO_CHMOD +# define NO_SYSLOG +# endif + +# define get_last_sys_error() errno +# define clear_sys_error() errno=0 +# define set_sys_error(e) errno=(e) + +/******************************************************************** + The Microsoft section + ********************************************************************/ +# if defined(OPENSSL_SYS_WIN32) && !defined(WIN32) +# define WIN32 +# endif +# if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +# endif +# if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS) +# define MSDOS +# endif + +# ifdef WIN32 +# undef get_last_sys_error +# undef clear_sys_error +# undef set_sys_error +# define get_last_sys_error() GetLastError() +# define clear_sys_error() SetLastError(0) +# define set_sys_error(e) SetLastError(e) +# if !defined(WINNT) +# define WIN_CONSOLE_BUG +# endif +# else +# endif + +# if (defined(WINDOWS) || defined(MSDOS)) + +# ifdef __DJGPP__ +# include +# include +# define _setmode setmode +# define _O_TEXT O_TEXT +# define _O_BINARY O_BINARY +# undef DEVRANDOM_EGD /* Neither MS-DOS nor FreeDOS provide 'egd' sockets. */ +# undef DEVRANDOM +# define DEVRANDOM "/dev/urandom\x24" +# endif /* __DJGPP__ */ + +# ifndef S_IFDIR +# define S_IFDIR _S_IFDIR +# endif + +# ifndef S_IFMT +# define S_IFMT _S_IFMT +# endif + +# if !defined(WINNT) && !defined(__DJGPP__) +# define NO_SYSLOG +# endif + +# ifdef WINDOWS +# if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT) + /* + * Defining _WIN32_WINNT here in e_os.h implies certain "discipline." + * Most notably we ought to check for availability of each specific + * routine that was introduced after denoted _WIN32_WINNT with + * GetProcAddress(). Normally newer functions are masked with higher + * _WIN32_WINNT in SDK headers. So that if you wish to use them in + * some module, you'd need to override _WIN32_WINNT definition in + * the target module in order to "reach for" prototypes, but replace + * calls to new functions with indirect calls. Alternatively it + * might be possible to achieve the goal by /DELAYLOAD-ing .DLLs + * and check for current OS version instead. + */ +# define _WIN32_WINNT 0x0501 +# endif +# if defined(_WIN32_WINNT) || defined(_WIN32_WCE) + /* + * Just like defining _WIN32_WINNT including winsock2.h implies + * certain "discipline" for maintaining [broad] binary compatibility. + * As long as structures are invariant among Winsock versions, + * it's sufficient to check for specific Winsock2 API availability + * at run-time [DSO_global_lookup is recommended]... + */ +# include +# include + /* + * Clang-based C++Builder 10.3.3 toolchains cannot find C inline + * definitions at link-time. This header defines WspiapiLoad() as an + * __inline function. https://quality.embarcadero.com/browse/RSP-33806 + */ +# if !defined(__BORLANDC__) || !defined(__clang__) +# include +# endif + /* yes, they have to be #included prior to */ +# endif +# include +# include +# include +# include +# if defined(_WIN32_WCE) && !defined(EACCES) +# define EACCES 13 +# endif +# include +# ifdef _WIN64 +# define strlen(s) _strlen31(s) +/* cut strings to 2GB */ +static __inline unsigned int _strlen31(const char *str) +{ + unsigned int len = 0; + while (*str && len < 0x80000000U) + str++, len++; + return len & 0x7FFFFFFF; +} +# endif +# include +# if defined(_MSC_VER) && !defined(_WIN32_WCE) && !defined(_DLL) && defined(stdin) +# if _MSC_VER>=1300 && _MSC_VER<1600 +# undef stdin +# undef stdout +# undef stderr +FILE *__iob_func(); +# define stdin (&__iob_func()[0]) +# define stdout (&__iob_func()[1]) +# define stderr (&__iob_func()[2]) +# endif +# endif +# endif +# include +# include + +# ifdef OPENSSL_SYS_WINCE +# define OPENSSL_NO_POSIX_IO +# endif + +# define EXIT(n) exit(n) +# define LIST_SEPARATOR_CHAR ';' +# ifndef W_OK +# define W_OK 2 +# endif +# ifndef R_OK +# define R_OK 4 +# endif +# ifdef OPENSSL_SYS_WINCE +# define DEFAULT_HOME "" +# else +# define DEFAULT_HOME "C:" +# endif + +/* Avoid Visual Studio 13 GetVersion deprecated problems */ +# if defined(_MSC_VER) && _MSC_VER>=1800 +# define check_winnt() (1) +# define check_win_minplat(x) (1) +# else +# define check_winnt() (GetVersion() < 0x80000000) +# define check_win_minplat(x) (LOBYTE(LOWORD(GetVersion())) >= (x)) +# endif + +# else /* The non-microsoft world */ + +# if defined(OPENSSL_SYS_VXWORKS) +# include +# else +# include +# endif + +# ifdef OPENSSL_SYS_VMS +# define VMS 1 + /* + * some programs don't include stdlib, so exit() and others give implicit + * function warnings + */ +# include +# if defined(__DECC) +# include +# else +# include +# endif +# define LIST_SEPARATOR_CHAR ',' + /* We don't have any well-defined random devices on VMS, yet... */ +# undef DEVRANDOM + /*- + We need to do this since VMS has the following coding on status codes: + + Bits 0-2: status type: 0 = warning, 1 = success, 2 = error, 3 = info ... + The important thing to know is that odd numbers are considered + good, while even ones are considered errors. + Bits 3-15: actual status number + Bits 16-27: facility number. 0 is considered "unknown" + Bits 28-31: control bits. If bit 28 is set, the shell won't try to + output the message (which, for random codes, just looks ugly) + + So, what we do here is to change 0 to 1 to get the default success status, + and everything else is shifted up to fit into the status number field, and + the status is tagged as an error, which is what is wanted here. + + Finally, we add the VMS C facility code 0x35a000, because there are some + programs, such as Perl, that will reinterpret the code back to something + POSIX. 'man perlvms' explains it further. + + NOTE: the perlvms manual wants to turn all codes 2 to 255 into success + codes (status type = 1). I couldn't disagree more. Fortunately, the + status type doesn't seem to bother Perl. + -- Richard Levitte + */ +# define EXIT(n) exit((n) ? (((n) << 3) | 2 | 0x10000000 | 0x35a000) : 1) + +# define DEFAULT_HOME "SYS$LOGIN:" + +# else + /* !defined VMS */ +# include +# include +# ifdef OPENSSL_SYS_WIN32_CYGWIN +# include +# include +# endif + +# define LIST_SEPARATOR_CHAR ':' +# define EXIT(n) exit(n) +# endif + +# endif + +/***********************************************/ + +# if defined(OPENSSL_SYS_WINDOWS) +# define strcasecmp _stricmp +# define strncasecmp _strnicmp +# if (_MSC_VER >= 1310) && !defined(_WIN32_WCE) +# define open _open +# define fdopen _fdopen +# define close _close +# ifndef strdup +# define strdup _strdup +# endif +# define unlink _unlink +# define fileno _fileno +# endif +# else +# include +# endif + +/* vxworks */ +# if defined(OPENSSL_SYS_VXWORKS) +# include +# include +# include +# include +# include +# include + +# define TTY_STRUCT int +# define sleep(a) taskDelay((a) * sysClkRateGet()) + +/* + * NOTE: these are implemented by helpers in database app! if the database is + * not linked, we need to implement them elsewhere + */ +struct hostent *gethostbyname(const char *name); +struct hostent *gethostbyaddr(const char *addr, int length, int type); +struct servent *getservbyname(const char *name, const char *proto); + +# endif +/* end vxworks */ + +/* system-specific variants defining ossl_sleep() */ +#ifdef OPENSSL_SYS_UNIX +# include +static ossl_inline void ossl_sleep(unsigned long millis) +{ +# ifdef OPENSSL_SYS_VXWORKS + struct timespec ts; + ts.tv_sec = (long int) (millis / 1000); + ts.tv_nsec = (long int) (millis % 1000) * 1000000ul; + nanosleep(&ts, NULL); +# elif defined(__TANDEM) +# if !defined(_REENTRANT) +# include + /* HPNS does not support usleep for non threaded apps */ + PROCESS_DELAY_(millis * 1000); +# elif defined(_SPT_MODEL_) +# include +# include + usleep(millis * 1000); +# else + usleep(millis * 1000); +# endif +# else + usleep(millis * 1000); +# endif +} +#elif defined(_WIN32) +# include +static ossl_inline void ossl_sleep(unsigned long millis) +{ + Sleep(millis); +} +#else +/* Fallback to a busy wait */ +static ossl_inline void ossl_sleep(unsigned long millis) +{ + struct timeval start, now; + unsigned long elapsedms; + + gettimeofday(&start, NULL); + do { + gettimeofday(&now, NULL); + elapsedms = (((now.tv_sec - start.tv_sec) * 1000000) + + now.tv_usec - start.tv_usec) / 1000; + } while (elapsedms < millis); +} +#endif /* defined OPENSSL_SYS_UNIX */ + +/* ----------------------------- HP NonStop -------------------------------- */ +/* Required to support platform variant without getpid() and pid_t. */ +# if defined(__TANDEM) && defined(_GUARDIAN_TARGET) +# include +# include +# define getservbyname(name,proto) getservbyname((char*)name,proto) +# define gethostbyname(name) gethostbyname((char*)name) +# define ioctlsocket(a,b,c) ioctl(a,b,c) +# ifdef NO_GETPID +inline int nssgetpid(); +# ifndef NSSGETPID_MACRO +# define NSSGETPID_MACRO +# include +# include + inline int nssgetpid() + { + short phandle[10]={0}; + union pseudo_pid { + struct { + short cpu; + short pin; + } cpu_pin ; + int ppid; + } ppid = { 0 }; + PROCESSHANDLE_GETMINE_(phandle); + PROCESSHANDLE_DECOMPOSE_(phandle, &ppid.cpu_pin.cpu, &ppid.cpu_pin.pin); + return ppid.ppid; + } +# define getpid(a) nssgetpid(a) +# endif /* NSSGETPID_MACRO */ +# endif /* NO_GETPID */ +/*# define setsockopt(a,b,c,d,f) setsockopt(a,b,c,(char*)d,f)*/ +/*# define getsockopt(a,b,c,d,f) getsockopt(a,b,c,(char*)d,f)*/ +/*# define connect(a,b,c) connect(a,(struct sockaddr *)b,c)*/ +/*# define bind(a,b,c) bind(a,(struct sockaddr *)b,c)*/ +/*# define sendto(a,b,c,d,e,f) sendto(a,(char*)b,c,d,(struct sockaddr *)e,f)*/ +# if defined(OPENSSL_THREADS) && !defined(_PUT_MODEL_) + /* + * HPNS SPT threads + */ +# define SPT_THREAD_SIGNAL 1 +# define SPT_THREAD_AWARE 1 +# include +# undef close +# define close spt_close +/* +# define get_last_socket_error() errno +# define clear_socket_error() errno=0 +# define ioctlsocket(a,b,c) ioctl(a,b,c) +# define closesocket(s) close(s) +# define readsocket(s,b,n) read((s),(char*)(b),(n)) +# define writesocket(s,b,n) write((s),(char*)(b),(n) +*/ +# define accept(a,b,c) accept(a,(struct sockaddr *)b,c) +# define recvfrom(a,b,c,d,e,f) recvfrom(a,b,(socklen_t)c,d,e,f) +# endif +# endif + +# ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION +# define CRYPTO_memcmp memcmp +# endif + +# ifndef OPENSSL_NO_SECURE_MEMORY + /* unistd.h defines _POSIX_VERSION */ +# if (defined(OPENSSL_SYS_UNIX) \ + && ( (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \ + || defined(__sun) || defined(__hpux) || defined(__sgi) \ + || defined(__osf__) )) \ + || defined(_WIN32) + /* secure memory is implemented */ +# else +# define OPENSSL_NO_SECURE_MEMORY +# endif +# endif + +#endif diff --git a/providers/common/capabilities.c b/providers/common/capabilities.c index f6d95197f0..edf7c9f768 100644 --- a/providers/common/capabilities.c +++ b/providers/common/capabilities.c @@ -17,7 +17,7 @@ #include "internal/nelem.h" #include "internal/tlsgroups.h" #include "prov/providercommon.h" -#include "e_os.h" +#include "internal/e_os.h" /* If neither ec or dh is available then we have no TLS-GROUP capabilities */ #if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) diff --git a/providers/fips/self_test.c b/providers/fips/self_test.c index e236bd421a..a41f49b887 100644 --- a/providers/fips/self_test.c +++ b/providers/fips/self_test.c @@ -15,7 +15,7 @@ #include #include #include -#include "e_os.h" +#include "internal/e_os.h" #include "prov/providercommon.h" /* diff --git a/providers/implementations/ciphers/cipher_cts.c b/providers/implementations/ciphers/cipher_cts.c index cb3372c646..aced2021f9 100644 --- a/providers/implementations/ciphers/cipher_cts.c +++ b/providers/implementations/ciphers/cipher_cts.c @@ -46,7 +46,7 @@ * Otherwise it is the same as CS2. */ -#include "e_os.h" /* strcasecmp */ +#include "internal/e_os.h" /* strcasecmp */ #include #include "prov/ciphercommon.h" #include "internal/nelem.h" diff --git a/providers/implementations/kdfs/hkdf.c b/providers/implementations/kdfs/hkdf.c index e014e32d5b..2238c321a7 100644 --- a/providers/implementations/kdfs/hkdf.c +++ b/providers/implementations/kdfs/hkdf.c @@ -29,7 +29,7 @@ #include "prov/providercommon.h" #include "prov/implementations.h" #include "prov/provider_util.h" -#include "e_os.h" +#include "internal/e_os.h" #define HKDF_MAXBUF 2048 diff --git a/providers/implementations/kdfs/kbkdf.c b/providers/implementations/kdfs/kbkdf.c index fb5c1c022e..7462eb6e94 100644 --- a/providers/implementations/kdfs/kbkdf.c +++ b/providers/implementations/kdfs/kbkdf.c @@ -44,7 +44,7 @@ #include "prov/provider_util.h" #include "prov/providercommon.h" -#include "e_os.h" +#include "internal/e_os.h" #define ossl_min(a, b) ((a) < (b)) ? (a) : (b) diff --git a/providers/implementations/kdfs/tls1_prf.c b/providers/implementations/kdfs/tls1_prf.c index 23436cf241..eba4da50e1 100644 --- a/providers/implementations/kdfs/tls1_prf.c +++ b/providers/implementations/kdfs/tls1_prf.c @@ -60,7 +60,7 @@ #include "prov/providercommon.h" #include "prov/implementations.h" #include "prov/provider_util.h" -#include "e_os.h" +#include "internal/e_os.h" static OSSL_FUNC_kdf_newctx_fn kdf_tls1_prf_new; static OSSL_FUNC_kdf_dupctx_fn kdf_tls1_prf_dup; diff --git a/providers/implementations/kdfs/x942kdf.c b/providers/implementations/kdfs/x942kdf.c index 4fb71835a2..3bf65aa3cd 100644 --- a/providers/implementations/kdfs/x942kdf.c +++ b/providers/implementations/kdfs/x942kdf.c @@ -8,7 +8,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include #include #include diff --git a/providers/implementations/kem/rsa_kem.c b/providers/implementations/kem/rsa_kem.c index 313ab133b3..201c80e648 100644 --- a/providers/implementations/kem/rsa_kem.c +++ b/providers/implementations/kem/rsa_kem.c @@ -13,7 +13,7 @@ */ #include "internal/deprecated.h" -#include "e_os.h" /* strcasecmp */ +#include "internal/e_os.h" /* strcasecmp */ #include #include #include diff --git a/providers/implementations/keymgmt/dsa_kmgmt.c b/providers/implementations/keymgmt/dsa_kmgmt.c index cf6daa4715..3ddafbd4c1 100644 --- a/providers/implementations/keymgmt/dsa_kmgmt.c +++ b/providers/implementations/keymgmt/dsa_kmgmt.c @@ -13,7 +13,7 @@ */ #include "internal/deprecated.h" -#include "e_os.h" /* strcasecmp */ +#include "internal/e_os.h" /* strcasecmp */ #include #include #include diff --git a/providers/implementations/keymgmt/ec_kmgmt.c b/providers/implementations/keymgmt/ec_kmgmt.c index dd66489bce..78dc69082f 100644 --- a/providers/implementations/keymgmt/ec_kmgmt.c +++ b/providers/implementations/keymgmt/ec_kmgmt.c @@ -13,7 +13,7 @@ */ #include "internal/deprecated.h" -#include "e_os.h" /* strcasecmp */ +#include "internal/e_os.h" /* strcasecmp */ #include #include #include diff --git a/providers/implementations/keymgmt/ecx_kmgmt.c b/providers/implementations/keymgmt/ecx_kmgmt.c index 42ae565429..9afcb6dc0a 100644 --- a/providers/implementations/keymgmt/ecx_kmgmt.c +++ b/providers/implementations/keymgmt/ecx_kmgmt.c @@ -10,7 +10,7 @@ #include #include /* For strcasecmp on Windows */ -#include "e_os.h" +#include "internal/e_os.h" #include #include #include diff --git a/providers/implementations/keymgmt/mac_legacy_kmgmt.c b/providers/implementations/keymgmt/mac_legacy_kmgmt.c index b1c3880277..73af2071bf 100644 --- a/providers/implementations/keymgmt/mac_legacy_kmgmt.c +++ b/providers/implementations/keymgmt/mac_legacy_kmgmt.c @@ -26,7 +26,7 @@ #include "prov/providercommon.h" #include "prov/provider_ctx.h" #include "prov/macsignature.h" -#include "e_os.h" /* strcasecmp */ +#include "internal/e_os.h" /* strcasecmp */ static OSSL_FUNC_keymgmt_new_fn mac_new; static OSSL_FUNC_keymgmt_free_fn mac_free; diff --git a/providers/implementations/rands/drbg_ctr.c b/providers/implementations/rands/drbg_ctr.c index dbe57b0d28..1384a43390 100644 --- a/providers/implementations/rands/drbg_ctr.c +++ b/providers/implementations/rands/drbg_ctr.c @@ -14,7 +14,7 @@ #include #include #include -#include "e_os.h" /* strcasecmp */ +#include "internal/e_os.h" /* strcasecmp */ #include "crypto/modes.h" #include "internal/thread_once.h" #include "prov/implementations.h" diff --git a/providers/implementations/rands/seeding/rand_unix.c b/providers/implementations/rands/seeding/rand_unix.c index f394927dae..6858d276cb 100644 --- a/providers/implementations/rands/seeding/rand_unix.c +++ b/providers/implementations/rands/seeding/rand_unix.c @@ -10,7 +10,7 @@ #ifndef _GNU_SOURCE # define _GNU_SOURCE #endif -#include "../e_os.h" +#include "internal/e_os.h" #include #include "internal/cryptlib.h" #include diff --git a/providers/implementations/rands/seeding/rand_vms.c b/providers/implementations/rands/seeding/rand_vms.c index 30a97bf6e4..ed4f75855d 100644 --- a/providers/implementations/rands/seeding/rand_vms.c +++ b/providers/implementations/rands/seeding/rand_vms.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #define __NEW_STARLET 1 /* New starlet definitions since VMS 7.0 */ #include diff --git a/providers/implementations/signature/rsa_sig.c b/providers/implementations/signature/rsa_sig.c index 14741dee9d..f543bdb17a 100644 --- a/providers/implementations/signature/rsa_sig.c +++ b/providers/implementations/signature/rsa_sig.c @@ -13,7 +13,7 @@ */ #include "internal/deprecated.h" -#include "e_os.h" /* strcasecmp */ +#include "internal/e_os.h" /* strcasecmp */ #include #include #include diff --git a/providers/implementations/storemgmt/file_store.c b/providers/implementations/storemgmt/file_store.c index dc93f08b10..461b7e468d 100644 --- a/providers/implementations/storemgmt/file_store.c +++ b/providers/implementations/storemgmt/file_store.c @@ -9,7 +9,7 @@ /* This file has quite some overlap with engines/e_loader_attic.c */ -#include "e_os.h" /* To get strncasecmp() on Windows */ +#include "internal/e_os.h" /* To get strncasecmp() on Windows */ #include #include diff --git a/ssl/d1_lib.c b/ssl/d1_lib.c index 95a34093c9..baedf390f6 100644 --- a/ssl/d1_lib.c +++ b/ssl/d1_lib.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include #include #include diff --git a/ssl/ssl_init.c b/ssl/ssl_init.c index e996a803e0..6a666ac0e7 100644 --- a/ssl/ssl_init.c +++ b/ssl/ssl_init.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" #include "internal/err.h" #include diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index cb7a52ab7e..9138cd659b 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -11,7 +11,7 @@ #include #include "ssl_local.h" -#include "e_os.h" +#include "internal/e_os.h" #include #include #include diff --git a/ssl/ssl_local.h b/ssl/ssl_local.h index 2c83505660..58a3e9e08a 100644 --- a/ssl/ssl_local.h +++ b/ssl/ssl_local.h @@ -12,7 +12,7 @@ #ifndef OSSL_SSL_LOCAL_H # define OSSL_SSL_LOCAL_H -# include "e_os.h" /* struct timeval for DTLS */ +# include "internal/e_os.h" /* struct timeval for DTLS */ # include # include # include diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c index 05af89379f..caceb50fb6 100644 --- a/test/evp_extra_test.c +++ b/test/evp_extra_test.c @@ -35,7 +35,7 @@ #include "internal/nelem.h" #include "internal/sizes.h" #include "crypto/evp.h" -#include "../e_os.h" /* strcasecmp */ +#include "internal/e_os.h" /* strcasecmp */ static OSSL_LIB_CTX *testctx = NULL; static char *testpropq = NULL; diff --git a/test/evp_libctx_test.c b/test/evp_libctx_test.c index e2663dc029..ada3bf01c8 100644 --- a/test/evp_libctx_test.c +++ b/test/evp_libctx_test.c @@ -33,7 +33,7 @@ #include "testutil.h" #include "internal/nelem.h" #include "crypto/bn_dh.h" /* _bignum_ffdhe2048_p */ -#include "../e_os.h" /* strcasecmp */ +#include "internal/e_os.h" /* strcasecmp */ static OSSL_LIB_CTX *libctx = NULL; static OSSL_PROVIDER *nullprov = NULL; diff --git a/test/evp_test.c b/test/evp_test.c index 5e106c64f0..6c4e64c159 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -12,7 +12,7 @@ #include #include #include -#include "../e_os.h" /* strcasecmp and strncasecmp */ +#include "internal/e_os.h" /* strcasecmp and strncasecmp */ #include #include #include diff --git a/test/helpers/ssltestlib.c b/test/helpers/ssltestlib.c index 795cff2660..7ece47edd6 100644 --- a/test/helpers/ssltestlib.c +++ b/test/helpers/ssltestlib.c @@ -12,7 +12,7 @@ #include "internal/nelem.h" #include "ssltestlib.h" #include "../testutil.h" -#include "e_os.h" /* for ossl_sleep() etc. */ +#include "internal/e_os.h" /* for ossl_sleep() etc. */ #ifdef OPENSSL_SYS_UNIX # include diff --git a/test/p_test.c b/test/p_test.c index 80f0784dd9..32a5e44117 100644 --- a/test/p_test.c +++ b/test/p_test.c @@ -26,7 +26,7 @@ # define OSSL_provider_init PROVIDER_INIT_FUNCTION_NAME #endif -#include "e_os.h" +#include "internal/e_os.h" #include #include #include diff --git a/test/secmemtest.c b/test/secmemtest.c index d0f9ba2e99..2b0a163747 100644 --- a/test/secmemtest.c +++ b/test/secmemtest.c @@ -10,7 +10,7 @@ #include #include "testutil.h" -#include "../e_os.h" +#include "internal/e_os.h" static int test_sec_mem(void) { diff --git a/test/ssl_old_test.c b/test/ssl_old_test.c index e7ac6dfba4..1b1983b7c3 100644 --- a/test/ssl_old_test.c +++ b/test/ssl_old_test.c @@ -9,7 +9,7 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" +#include "internal/e_os.h" /* Or gethostname won't be declared properly on Linux and GNU platforms. */ #ifndef _BSD_SOURCE -- cgit v1.2.3