diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2022-11-13 21:34:16 +0100 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2022-12-22 12:08:01 +0100 |
commit | b49d8da7745477bde6e9598ed87524e1afe1829c (patch) | |
tree | 1866d669a260b5eb73405ae8a0f6fcab49b4b338 | |
parent | 00323667e3b725be4c193c3242863e3a521ac19e (diff) |
Fix possible UB in init_info_strings
"openssl version -c" may create undefined behavior in the shift:
crypto/info.c:42:50: runtime error: left shift of 4275712515
by 32 places cannot be represented in type 'long long int'
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19668)
(cherry picked from commit ee17dcc7ffbd6621f82838c75792f19aa97bd5d7)
-rw-r--r-- | crypto/info.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crypto/info.c b/crypto/info.c index a106e8c885..f66639f563 100644 --- a/crypto/info.c +++ b/crypto/info.c @@ -45,10 +45,10 @@ DEFINE_RUN_ONCE_STATIC(init_info_strings) BIO_snprintf(ossl_cpu_info_str, sizeof(ossl_cpu_info_str), CPUINFO_PREFIX "OPENSSL_ia32cap=0x%llx:0x%llx", - (long long)OPENSSL_ia32cap_P[0] | - (long long)OPENSSL_ia32cap_P[1] << 32, - (long long)OPENSSL_ia32cap_P[2] | - (long long)OPENSSL_ia32cap_P[3] << 32); + (unsigned long long)OPENSSL_ia32cap_P[0] | + (unsigned long long)OPENSSL_ia32cap_P[1] << 32, + (unsigned long long)OPENSSL_ia32cap_P[2] | + (unsigned long long)OPENSSL_ia32cap_P[3] << 32); if ((env = getenv("OPENSSL_ia32cap")) != NULL) BIO_snprintf(ossl_cpu_info_str + strlen(ossl_cpu_info_str), sizeof(ossl_cpu_info_str) - strlen(ossl_cpu_info_str), |