Laszlo Ersek
2015-06-23 13:34:25 UTC
Git commit f93f78ea70 (SVN r17633), with subject "CryptoPkg: Update
openssl patch file from 0.9.8zf to 1.0.2c", replaced the file
CryptoPkg/Library/OpensslLib/EDKII_openssl-0.9.8zf.patch
with
CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2c.patch
In the process, two hunks were lost that used to add EFIAPI to the
declaration of the variadic function ERR_add_error_data().
The VA_START() macro, from "MdePkg/Include/Base.h", expands to an
EFIAPI-dependent implementation when
!defined(__CC_ARM) && (!defined(__GNUC__) ||
defined(NO_BUILTIN_VA_FUNCS))
Under such circumstances, the va_start() macro invocation in
ERR_add_error_data() -- which is translated to VA_START() by
"CryptoPkg/Include/OpenSslSupport.h" -- results in EFIAPI-dependent code,
but callers of the function pass the arguments incorrectly, because the
declaration doesn't state EFIAPI.
This leads to crashes when ERR_add_error_vdata(), called by
ERR_add_error_data(), tries to access the arguments forwarded to it.
Restore the missing hunk from before SVN r17633.
Cc: Qin Long <***@intel.com>
Cc: Ard Biesheuvel <***@linaro.org>
Cc: Gary Ching-Pang Lin <***@suse.com>
Cc: Peter Jones <***@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <***@redhat.com>
---
.../Library/OpensslLib/EDKII_openssl-1.0.2c.patch | 34 ++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2c.patch b/CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2c.patch
index 54e14d8..0d9575e 100644
--- a/CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2c.patch
+++ b/CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2c.patch
@@ -344,3 +344,37 @@ diff U3 crypto/opensslconf.h crypto/opensslconf.h
#endif
#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)
+diff U3 crypto/err/err.c crypto/err/err.c
+--- crypto/err/err.c
++++ crypto/err/err.c
+@@ -1072,7 +1072,12 @@ void ERR_set_error_data(char *data, int flags)
+ es->err_data_flags[i] = flags;
+ }
+
++/* Add EFIAPI for UEFI version. */
++#if defined(OPENSSL_SYS_UEFI)
++void EFIAPI ERR_add_error_data(int num, ...)
++#else
+ void ERR_add_error_data(int num, ...)
++#endif
+ {
+ va_list args;
+ va_start(args, num);
+diff U3 crypto/err/err.h crypto/err/err.h
+--- crypto/err/err.h
++++ crypto/err/err.h
+@@ -344,7 +344,14 @@ void ERR_print_errors_fp(FILE *fp);
+ # ifndef OPENSSL_NO_BIO
+ void ERR_print_errors(BIO *bp);
+ # endif
++
++/* Add EFIAPI for UEFI version. */
++#if defined(OPENSSL_SYS_UEFI)
++void EFIAPI ERR_add_error_data(int num, ...);
++#else
+ void ERR_add_error_data(int num, ...);
++#endif
++
+ void ERR_add_error_vdata(int num, va_list args);
+ void ERR_load_strings(int lib, ERR_STRING_DATA str[]);
+ void ERR_unload_strings(int lib, ERR_STRING_DATA str[]);
openssl patch file from 0.9.8zf to 1.0.2c", replaced the file
CryptoPkg/Library/OpensslLib/EDKII_openssl-0.9.8zf.patch
with
CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2c.patch
In the process, two hunks were lost that used to add EFIAPI to the
declaration of the variadic function ERR_add_error_data().
The VA_START() macro, from "MdePkg/Include/Base.h", expands to an
EFIAPI-dependent implementation when
!defined(__CC_ARM) && (!defined(__GNUC__) ||
defined(NO_BUILTIN_VA_FUNCS))
Under such circumstances, the va_start() macro invocation in
ERR_add_error_data() -- which is translated to VA_START() by
"CryptoPkg/Include/OpenSslSupport.h" -- results in EFIAPI-dependent code,
but callers of the function pass the arguments incorrectly, because the
declaration doesn't state EFIAPI.
This leads to crashes when ERR_add_error_vdata(), called by
ERR_add_error_data(), tries to access the arguments forwarded to it.
Restore the missing hunk from before SVN r17633.
Cc: Qin Long <***@intel.com>
Cc: Ard Biesheuvel <***@linaro.org>
Cc: Gary Ching-Pang Lin <***@suse.com>
Cc: Peter Jones <***@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <***@redhat.com>
---
.../Library/OpensslLib/EDKII_openssl-1.0.2c.patch | 34 ++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2c.patch b/CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2c.patch
index 54e14d8..0d9575e 100644
--- a/CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2c.patch
+++ b/CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2c.patch
@@ -344,3 +344,37 @@ diff U3 crypto/opensslconf.h crypto/opensslconf.h
#endif
#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)
+diff U3 crypto/err/err.c crypto/err/err.c
+--- crypto/err/err.c
++++ crypto/err/err.c
+@@ -1072,7 +1072,12 @@ void ERR_set_error_data(char *data, int flags)
+ es->err_data_flags[i] = flags;
+ }
+
++/* Add EFIAPI for UEFI version. */
++#if defined(OPENSSL_SYS_UEFI)
++void EFIAPI ERR_add_error_data(int num, ...)
++#else
+ void ERR_add_error_data(int num, ...)
++#endif
+ {
+ va_list args;
+ va_start(args, num);
+diff U3 crypto/err/err.h crypto/err/err.h
+--- crypto/err/err.h
++++ crypto/err/err.h
+@@ -344,7 +344,14 @@ void ERR_print_errors_fp(FILE *fp);
+ # ifndef OPENSSL_NO_BIO
+ void ERR_print_errors(BIO *bp);
+ # endif
++
++/* Add EFIAPI for UEFI version. */
++#if defined(OPENSSL_SYS_UEFI)
++void EFIAPI ERR_add_error_data(int num, ...);
++#else
+ void ERR_add_error_data(int num, ...);
++#endif
++
+ void ERR_add_error_vdata(int num, va_list args);
+ void ERR_load_strings(int lib, ERR_STRING_DATA str[]);
+ void ERR_unload_strings(int lib, ERR_STRING_DATA str[]);
--
1.8.3.1
1.8.3.1