]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
compat_openssl: fix for LibreSSL 4.1.0
authororbea <orbea@riseup.net>
Wed, 30 Apr 2025 18:47:13 +0000 (11:47 -0700)
committerDavid Goulet <dgoulet@torproject.org>
Mon, 5 May 2025 16:33:03 +0000 (12:33 -0400)
Starting with LibreSSL 4.1.0 this now causes a build failure:

src/lib/tls/tortls_openssl.c: In function 'tor_tls_setup_session_secret_cb':
src/lib/tls/tortls_openssl.c:1059:39: error: passing argument 2 of 'SSL_set_session_secret_cb' from incompatible pointer type [-Wincompatible-pointer-types]
 1059 |   SSL_set_session_secret_cb(tls->ssl, tor_tls_session_secret_cb, NULL);
      |                                       ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                                       |
      |                                       int (*)(SSL *, void *, int *, struct stack_st_SSL_CIPHER *, SSL_CIPHER **, void *) {aka int (*)(struct ssl_st *, void *, int *, struct stack_st_SSL_CIPHER *, struct ssl_cipher_st **, void *)}
In file included from src/lib/tls/tortls_openssl.c:48:
/usr/include/openssl/ssl.h:1489:30: note: expected 'tls_session_secret_cb_fn' {aka 'int (*)(struct ssl_st *, void *, int *, struct stack_st_SSL_CIPHER *, const struct ssl_cipher_st **, void *)'} but argument is of type 'int (*)(SSL *, void *, int *, struct stack_st_SSL_CIPHER *, SSL_CIPHER **, void *)' {aka 'int (*)(struct ssl_st *, void *, int *, struct stack_st_SSL_CIPHER *, struct ssl_cipher_st **, void *)'}
 1489 |     tls_session_secret_cb_fn tls_session_secret_cb, void *arg);
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

Signed-off-by: orbea <orbea@riseup.net>
src/lib/crypt_ops/compat_openssl.h

index c5eccdb0150cfc3d714e0127848bfecfd64cb632..07efc534023f3f0a09a5ca737f12cc33da4b1e0e 100644 (file)
   (((st) == SSL3_ST_SW_SRVR_HELLO_A) ||    \
    ((st) == SSL3_ST_SW_SRVR_HELLO_B))
 #define OSSL_HANDSHAKE_STATE int
-#define CONST_IF_OPENSSL_1_1_API
 #else
 #define STATE_IS_SW_SERVER_HELLO(st) \
   ((st) == TLS_ST_SW_SRVR_HELLO)
+#endif
+
+#if !defined(OPENSSL_1_1_API) || (defined(LIBRESSL_VERSION_NUMBER) && \
+   LIBRESSL_VERSION_NUMBER < 0x4010000fL)
+#define CONST_IF_OPENSSL_1_1_API
+#else
 #define CONST_IF_OPENSSL_1_1_API const
 #endif