tpm2-software / tpm2-tss-engine

OpenSSL Engine for TPM2 devices
https://tpm2-software.github.io
BSD 3-Clause "New" or "Revised" License
150 stars 100 forks source link

Fix mismatch of OpenSSL function signatures that cause errors with gc… #283

Closed mgerstner closed 2 months ago

mgerstner commented 5 months ago

…c-14

Building with gcc-14 fails with diagnostics like this:

src/tpm2-tss-engine-rsa.c:805:46: error: passing argument 2 of 'EVP_PKEY_meth_set_copy' from incompatible pointer type [-Wincompatible-pointer-types]
  805 |     EVP_PKEY_meth_set_copy(pkey_rsa_methods, rsa_pkey_copy);
      |                                              ^~~~~~~~~~~~~
      |                                              |
      |                                              int (*)(EVP_PKEY_CTX *, EVP_PKEY_CTX *) {aka int (*)(struct evp_pkey_ctx_st *, struct evp_pkey_ctx_st *)}
/usr/include/openssl/evp.h:2005:36: note: expected 'int (*)(EVP_PKEY_CTX *, const EVP_PKEY_CTX *)' {aka 'int (*)(struct evp_pkey_ctx_st *, const struct evp_pkey_ctx_st *)'} but argument is of type 'int (*)(EVP_PKEY_CTX *, EVP_PKEY_CTX *)' {aka 'int (*)(struct evp_pkey_ctx_st *, struct evp_pkey_ctx_st *)'}

A look into OpenSSL upstream shows that these functions have always had const src parameters. Thus this error was simply not detected by earlier compiler versions.

bluca commented 2 months ago

@williamcroberts any chance you could please look into this PR? The project fails to build with GCC 14

williamcroberts commented 2 months ago

@mgerstner can you sign off on your commit and re-push? Otherwise, LGTM.

mgerstner commented 2 months ago

@mgerstner can you sign off on your commit and re-push? Otherwise, LGTM.

I just did so.