From bf74cf35cf47bfa44a89a6f8c3e52a3ec76d828f Mon Sep 17 00:00:00 2001 From: Neil Horman Date: Wed, 26 Jun 2024 11:52:22 -0400 Subject: [PATCH] Fixes for defaults code Fix up some indenting, and ensure that the run_once routines don't get defined if OSSL_WINCTX isn't defined to avoid compiler errors Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/24450) --- NOTES-WINDOWS.md | 4 +--- apps/version.c | 5 ++++- crypto/defaults.c | 12 ++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/NOTES-WINDOWS.md b/NOTES-WINDOWS.md index f7984cda0c..21c82e8a76 100644 --- a/NOTES-WINDOWS.md +++ b/NOTES-WINDOWS.md @@ -132,11 +132,9 @@ A summary table of behavior on Windows platforms |`OSSL_WINCTX`|Registry key|OpenSSL Behavior | |-------------|------------|------------------------------------------| |Defined | Defined |OpenSSL Reads Paths from Registry | -|Defined | Undefined |OpenSSL returns errors on module/conf load| +|Defined | Undefined |OpenSSL returns errors on module/conf load| |Undefined | N/A |OpenSSL uses build time defaults | - - Special notes for Universal Windows Platform builds, aka `VC-*-UWP` ------------------------------------------------------------------- diff --git a/apps/version.c b/apps/version.c index 4da8d27447..efd23a4064 100644 --- a/apps/version.c +++ b/apps/version.c @@ -18,7 +18,10 @@ typedef enum OPTION_choice { OPT_COMMON, - OPT_B, OPT_D, OPT_E, OPT_M, OPT_F, OPT_O, OPT_P, OPT_V, OPT_A, OPT_R, OPT_C, OPT_W + OPT_B, OPT_D, OPT_E, OPT_M, OPT_F, OPT_O, OPT_P, OPT_V, OPT_A, OPT_R, OPT_C +#if defined(_WIN32) + ,OPT_W +#endif } OPTION_CHOICE; const OPTIONS version_options[] = { diff --git a/crypto/defaults.c b/crypto/defaults.c index 2735efc63a..f9bd077686 100644 --- a/crypto/defaults.c +++ b/crypto/defaults.c @@ -13,14 +13,14 @@ #include "internal/cryptlib.h" #include "internal/e_os.h" -#if defined(_WIN32) +#if defined(_WIN32) && defined(OSSL_WINCTX) # define TOSTR(x) #x # define MAKESTR(x) TOSTR(x) # define NOQUOTE(x) x -#if defined(OSSL_WINCTX) +# if defined(OSSL_WINCTX) # define REGISTRY_KEY "SOFTWARE\\WOW6432Node\\OpenSSL" ##"-"## NOQUOTE(OPENSSL_VERSION_STR) ##"-"## MAKESTR(OSSL_WINCTX) -#endif +# endif /** * @brief The directory where OpenSSL is installed. @@ -63,7 +63,7 @@ static char *modulesdirptr = NULL; static char *get_windows_regdirs(char *dst, LPCTSTR valuename) { char *retval = NULL; -#ifdef REGISTY_KEY +# ifdef REGISTRY_KEY DWORD keysize; DWORD ktype; HKEY hkey; @@ -104,7 +104,7 @@ static char *get_windows_regdirs(char *dst, LPCTSTR valuename) out: OPENSSL_free(tempstr); RegCloseKey(hkey); -#endif +# endif /* REGISTRY_KEY */ return retval; } @@ -135,7 +135,7 @@ DEFINE_RUN_ONCE_STATIC(do_defaults_setup) return 1; } -#endif +#endif /* defined(_WIN32) && defined(OSSL_WINCTX) */ /** * @brief Get the directory where OpenSSL is installed.