Skip to content

Commit a173d3e

Browse files
authored
configure: fix usage of libgpg-error with --with-local-libgcrypt (ntop#1472)
Right now, using external libgcrypt, nDPI is not linked to libgpg-error because configure script never checks for it. ``` ivan@ivan-Latitude-E6540:~/svnrepos/nDPI(dev)$ CC=gcc-11 CXX=g++-11 CFLAGS="-O3 -g -Werror" ./autogen.sh --enable-debug-messages --with-pcre --with-local-libgcrypt && make -s -j [...] checking for numa_available in -lnuma... yes checking for pcap_open_live in -lpcap... yes checking for pthread_setaffinity_np in -lpthread... yes checking for gcry_cipher_checktag in -lgcrypt... yes <------- missing check for libgpg-error checking for pcre_compile in -lpcre... yes checking that generated files are newer than configure... done [...] ivan@ivan-Latitude-E6540:~/svnrepos/nDPI(dev)$ grep HAVE_LIBGPG_ERROR src/include/ndpi_config.h /* #undef HAVE_LIBGPG_ERROR */ ``` Make both libgcrypt and libgpg-error mandatory if `--with-local-libgcrypt` is used. Technically speaking, libgpg-error might be optional, because it is used only for debug messages. However having both libraries mandatory slightly simplified the logic. In most environments, libgpg-error is a dependency of libgcrypt anyway, so having both libraries should be the standard case.
1 parent 95a3d4f commit a173d3e

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

configure.ac

+3-9
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,9 @@ dnl> libgcrypt (external)
248248
USE_HOST_LIBGCRYPT=0
249249
AS_IF([test "${with_local_libgcrypt+set}" = set],[
250250
USE_HOST_LIBGCRYPT=1
251-
AC_CHECK_LIB(gcrypt, gcry_cipher_checktag)
252-
if test "x$ac_cv_lib_gcrypt_gcry_cipher_checktag" = xyes; then :
253-
ADDITIONAL_LIBS="${ADDITIONAL_LIBS} -lgcrypt"
254-
else
255-
$as_unset ac_cv_lib_gcrypt_gcry_cipher_checktag
256-
AC_CHECK_LIB(gpg-error, gpg_strerror_r, [], AC_MSG_ERROR([libgpg-error required (because of --with-local-libgcrypt) but not found or too old.]))
257-
AC_CHECK_LIB(gcrypt, gcry_cipher_checktag, [], AC_MSG_ERROR([libgcrypt required (because of --with-local-libgcrypt) but not found or too old.]))
258-
ADDITIONAL_LIBS="${ADDITIONAL_LIBS} -lgcrypt -lgpg-error"
259-
fi
251+
AC_CHECK_LIB(gpg-error, gpg_strerror_r, [], AC_MSG_ERROR([libgpg-error required (because of --with-local-libgcrypt) but not found or too old.]))
252+
AC_CHECK_LIB(gcrypt, gcry_cipher_checktag, [], AC_MSG_ERROR([libgcrypt required (because of --with-local-libgcrypt) but not found or too old.]))
253+
ADDITIONAL_LIBS="${ADDITIONAL_LIBS} -lgcrypt -lgpg-error"
260254
AC_DEFINE_UNQUOTED(USE_HOST_LIBGCRYPT, 1, [Use locally installed libgcrypt instead of builtin gcrypt-light])
261255
])
262256

src/lib/protocols/quic.c

-5
Original file line numberDiff line numberDiff line change
@@ -246,16 +246,11 @@ static uint16_t gquic_get_u16(const uint8_t *buf, uint32_t version)
246246
#ifdef DEBUG_CRYPT
247247
char *__gcry_err(gpg_error_t err, char *buf, size_t buflen)
248248
{
249-
#if defined(HAVE_LIBGPG_ERROR) || !defined(USE_HOST_LIBGCRYPT)
250249
gpg_strerror_r(err, buf, buflen);
251250
/* I am not sure if the string will be always null-terminated...
252251
Better safe than sorry */
253252
if(buflen > 0)
254253
buf[buflen - 1] = '\0';
255-
#else
256-
if(buflen > 0)
257-
buf[0] = '\0';
258-
#endif
259254
return buf;
260255
}
261256
#endif /* DEBUG_CRYPT */

0 commit comments

Comments
 (0)