From: Amos Jeffries Date: Tue, 30 Dec 2014 13:40:33 +0000 (-0800) Subject: Fix 64-bit compile issues in rev.13785 X-Git-Tag: merge-candidate-3-v1~405 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f9ef3ed8cfa34f20a4625d711cc388b6307d8069;p=thirdparty%2Fsquid.git Fix 64-bit compile issues in rev.13785 The Nettle 3.0 library API imported and used by rev.13785 defines function symbols with size_t parameters where earlier libraries used 'unsigned'. This matters on 64-bit systems where unsigned is a 'int' and size_t a 'long' - implicit conversion is not possible. Explicitly detect the size_t API existence during ./configure time and use the built-in logics if supplied Nettle library is an older version. --- diff --git a/configure.ac b/configure.ac index 50660c6a83..5aa63fdc01 100644 --- a/configure.ac +++ b/configure.ac @@ -1199,8 +1199,32 @@ case "$with_nettle" in if test "x$with_nettle" != "xno" ; then AC_CHECK_LIB(nettle, nettle_md5_init,[ NETTLELIB="$NETTLELIBDIR -lnettle" - AC_CHECK_HEADERS(nettle/md5.h nettle/base64.h) + AC_CHECK_HEADERS(nettle/md5.h) ],[with_nettle=no]) + if test "x$with_nettle" != "xno" ; then + # Base64 uses the nettle 3.0 API + # which matters on 64-bit systems + AC_CHECK_HEADERS(nettle/base64.h) + AC_MSG_CHECKING([for Nettle 3.0 API compatibility]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +# include +# include +# include + ]],[[ + uint8_t inData[10]; inData[0] = '\0'; + size_t srcLen = 0; + struct base64_decode_ctx ctx; + base64_decode_init(&ctx); + uint8_t outData[10]; + size_t dstLen = 0; + if (!base64_decode_update(&ctx, &dstLen, outData, srcLen, inData) || + !base64_decode_final(&ctx)) { + return 1; + } + ]])],[AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_NETTLE30_BASE64,1,[set to 1 if Nettle 3.0 API will link]) + ],[AC_MSG_RESULT(no)]) + fi fi AC_MSG_NOTICE([Using Nettle cryptographic library: ${with_nettle:=yes}]) AC_SUBST(NETTLELIB) diff --git a/include/base64.h b/include/base64.h index 35cc7ef710..fdf09d3ce4 100644 --- a/include/base64.h +++ b/include/base64.h @@ -9,7 +9,7 @@ #ifndef _SQUID_BASE64_H #define _SQUID_BASE64_H -#if HAVE_NETTLE_BASE64_H +#if HAVE_NETTLE_BASE64_H && HAVE_NETTLE30_BASE64 #include #else /* Base64 functions copied from Nettle 3.0 under GPLv2, with adjustments */ diff --git a/lib/base64.c b/lib/base64.c index 3926045fe2..4915494942 100644 --- a/lib/base64.c +++ b/lib/base64.c @@ -13,7 +13,7 @@ #include "squid.h" #include "base64.h" -#if !HAVE_NETTLE_BASE64_H +#if !HAVE_NETTLE_BASE64_H || !HAVE_NETTLE30_BASE64 #if HAVE_STDLIB_H #include @@ -268,5 +268,5 @@ base64_encode_final(struct base64_encode_ctx *ctx, return done; } -#endif /* HAVE_NETTLE_BASE64_H */ +#endif /* !HAVE_NETTLE_BASE64_H || !HAVE_NETTLE30_BASE64 */