Skip to content

Commit

Permalink
pppd: Fix build without OpenSSL (#533)
Browse files Browse the repository at this point in the history
The symbol OPENSSL_VERSION_NUMBER is not defined when pppd is
compiled without OpenSSL support, so it evaluates to zero.
This results in the following linker error:

crypto.c:241: undefined reference to `ERR_free_strings'

Signed-off-by: Tomas Paukrt <[email protected]>
  • Loading branch information
tpaukrt authored Nov 21, 2024
1 parent 616102e commit 5f6eabd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pppd/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#ifdef PPP_WITH_OPENSSL
#include <openssl/opensslv.h>
#include <openssl/err.h>
#endif

#if OPENSSL_VERSION_NUMBER >= 0x30000000L
#include <openssl/provider.h>
Expand All @@ -53,6 +52,7 @@ struct crypto_ctx {
OSSL_PROVIDER *provider;
} g_crypto_ctx;
#endif
#endif

PPP_MD_CTX *PPP_MD_CTX_new()
{
Expand Down Expand Up @@ -200,6 +200,7 @@ int PPP_crypto_init()
{
int retval = 0;

#ifdef PPP_WITH_OPENSSL
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
g_crypto_ctx.legacy = OSSL_PROVIDER_load(NULL, "legacy");
if (g_crypto_ctx.legacy == NULL)
Expand All @@ -214,6 +215,7 @@ int PPP_crypto_init()
PPP_crypto_error("Could not load default provider");
goto done;
}
#endif
#endif

retval = 1;
Expand All @@ -225,6 +227,7 @@ int PPP_crypto_init()

int PPP_crypto_deinit()
{
#ifdef PPP_WITH_OPENSSL
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
if (g_crypto_ctx.legacy) {
OSSL_PROVIDER_unload(g_crypto_ctx.legacy);
Expand All @@ -239,6 +242,7 @@ int PPP_crypto_deinit()

#if OPENSSL_VERSION_NUMBER < 0x10100000L
ERR_free_strings();
#endif
#endif
return 1;
}
Expand Down

0 comments on commit 5f6eabd

Please sign in to comment.