0002-fix-build-with-libressl-3.5.0.patch 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. From 5c8511384f1d41f9c2a131604d5cb2dbc1c0aec9 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Fri, 24 Feb 2023 12:23:56 +0100
  4. Subject: [PATCH] fix build with libressl >= 3.5.0
  5. Fix the following build failure with libressl >= 3.5.0:
  6. tls.c:113:17: error: static declaration of 'OPENSSL_cleanup' follows non-static declaration
  7. 113 | static void OPENSSL_cleanup(void)
  8. | ^~~~~~~~~~~~~~~
  9. In file included from /home/thomas/autobuild/instance-3/output-1/host/mips-buildroot-linux-gnu/sysroot/usr/include/openssl/bio.h:69,
  10. from /home/thomas/autobuild/instance-3/output-1/host/mips-buildroot-linux-gnu/sysroot/usr/include/openssl/evp.h:67,
  11. from /home/thomas/autobuild/instance-3/output-1/host/mips-buildroot-linux-gnu/sysroot/usr/include/openssl/hmac.h:67,
  12. from /home/thomas/autobuild/instance-3/output-1/host/mips-buildroot-linux-gnu/sysroot/usr/include/openssl/ssl.h:150,
  13. from ../../../include/zbxcomms.h:65,
  14. from tls.c:20:
  15. /home/thomas/autobuild/instance-3/output-1/host/mips-buildroot-linux-gnu/sysroot/usr/include/openssl/crypto.h:565:6: note: previous declaration of 'OPENSSL_cleanup' with type 'void(void)'
  16. 565 | void OPENSSL_cleanup(void);
  17. | ^~~~~~~~~~~~~~~
  18. In file included from tls.c:20:
  19. tls.c: In function 'zbx_log_ciphersuites':
  20. ../../../include/zbxcomms.h:222:75: error: invalid use of incomplete typedef 'SSL_CTX' {aka 'struct ssl_ctx_st'}
  21. 222 | # define SSL_CTX_get_ciphers(ciphers) ((ciphers)->cipher_list)
  22. | ^~
  23. tls.c:1415:31: note: in expansion of macro 'SSL_CTX_get_ciphers'
  24. 1415 | cipher_list = SSL_CTX_get_ciphers(ciphers);
  25. | ^~~~~~~~~~~~~~~~~~~
  26. Fixes:
  27. - http://autobuild.buildroot.org/results/acdfcb17b39d438ccf5e4621707a10f60577d233
  28. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  29. [Upstream status: not sent (no feedback on first patch)]
  30. ---
  31. include/zbxcomms.h | 3 ++-
  32. src/libs/zbxcomms/tls.c | 5 +++--
  33. 2 files changed, 5 insertions(+), 3 deletions(-)
  34. diff --git a/include/zbxcomms.h b/include/zbxcomms.h
  35. index e7d74dbd0f..d6efa358fe 100644
  36. --- a/include/zbxcomms.h
  37. +++ b/include/zbxcomms.h
  38. @@ -253,7 +253,8 @@ int zbx_telnet_execute(ZBX_SOCKET socket_fd, const char *command, AGENT_RESULT *
  39. /* TLS BLOCK */
  40. #if defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL)
  41. -#if defined(HAVE_OPENSSL) && OPENSSL_VERSION_NUMBER < 0x1010000fL || defined(LIBRESSL_VERSION_NUMBER)
  42. +#if defined(HAVE_OPENSSL) && OPENSSL_VERSION_NUMBER < 0x1010000fL || \
  43. + defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x3050000fL
  44. # if !defined(LIBRESSL_VERSION_NUMBER)
  45. # define OPENSSL_INIT_LOAD_SSL_STRINGS 0
  46. # define OPENSSL_INIT_LOAD_CRYPTO_STRINGS 0
  47. diff --git a/src/libs/zbxcomms/tls.c b/src/libs/zbxcomms/tls.c
  48. index 54ab0a6ef4..bd4075b3e4 100644
  49. --- a/src/libs/zbxcomms/tls.c
  50. +++ b/src/libs/zbxcomms/tls.c
  51. @@ -30,8 +30,9 @@
  52. #include "zbxstr.h"
  53. #include "zbxtime.h"
  54. -#if defined(HAVE_OPENSSL) && OPENSSL_VERSION_NUMBER < 0x1010000fL || defined(LIBRESSL_VERSION_NUMBER)
  55. -/* for OpenSSL 1.0.1/1.0.2 (before 1.1.0) or LibreSSL */
  56. +#if defined(HAVE_OPENSSL) && OPENSSL_VERSION_NUMBER < 0x1010000fL || \
  57. + defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x3050000fL
  58. +/* for OpenSSL 1.0.1/1.0.2 (before 1.1.0) or LibreSSL (before 3.5.0) */
  59. /* mutexes for multi-threaded OpenSSL (see "man 3ssl threads" and example in crypto/threads/mttest.c) */
  60. --
  61. 2.39.1