Skip to content

Commit

Permalink
configure.ac: add crypto libs late
Browse files Browse the repository at this point in the history
Otherwise crypto libs are linked for feature tests, which may
cause unwanted detections. For example LibreSSL publishes the
function `explicit_bzero()`, which masks the system alternative,
e.g. memset_s() on macOS. Then when trying to compile libssh2,
the declaration is missing:

```
bcrypt_pbkdf.c:93:5: error: implicit declaration of function 'explicit_bzero' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    _libssh2_explicit_zero(ciphertext, sizeof(ciphertext));
    ^
../src/misc.h:50:43: note: expanded from macro '_libssh2_explicit_zero'
                                          ^
```

Fix this by adding crypto libs to `LIBS` at the very end of the
configuration process.

Regression from 4f0f4bf
  • Loading branch information
vszakats committed Apr 28, 2023
1 parent edffe55 commit d4f58f0
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions configure.ac
Expand Up @@ -117,18 +117,6 @@ else
test "$found_crypto_str" = "" && found_crypto_str="$found_crypto"
fi

if test "$found_crypto" = "openssl"; then
LIBS="${LIBS} ${LTLIBSSL}"
elif test "$found_crypto" = "wolfssl"; then
LIBS="${LIBS} ${LTLIBWOLFSSL}"
elif test "$found_crypto" = "libgcrypt"; then
LIBS="${LIBS} ${LTLIBGCRYPT}"
elif test "$found_crypto" = "wincng"; then
LIBS="${LIBS} ${LTLIBBCRYPT}"
elif test "$found_crypto" = "mbedtls"; then
LIBS="${LIBS} ${LTLIBMBEDCRYPTO}"
fi

# libz

AC_ARG_WITH([libz],
Expand Down Expand Up @@ -377,6 +365,19 @@ AM_CONDITIONAL([HOST_WINDOWS], [test "x$host_windows" = "xyes"])
# Configure parameters
LIBSSH2_CHECK_OPTION_WERROR

# Append crypto lib
if test "$found_crypto" = "openssl"; then
LIBS="${LIBS} ${LTLIBSSL}"
elif test "$found_crypto" = "wolfssl"; then
LIBS="${LIBS} ${LTLIBWOLFSSL}"
elif test "$found_crypto" = "libgcrypt"; then
LIBS="${LIBS} ${LTLIBGCRYPT}"
elif test "$found_crypto" = "wincng"; then
LIBS="${LIBS} ${LTLIBBCRYPT}"
elif test "$found_crypto" = "mbedtls"; then
LIBS="${LIBS} ${LTLIBMBEDCRYPTO}"
fi

AC_CONFIG_FILES([Makefile
src/Makefile
tests/Makefile
Expand Down

0 comments on commit d4f58f0

Please sign in to comment.