mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-13 18:55:10 +01:00
Merge pull request #3767 from bluca/libbsd
Problems: reimplementation of strlcpy, CMake does not use pkg-config for NSS, wrong pc generated by autoconf with GNUTLS
This commit is contained in:
commit
73eb1eac05
@ -92,6 +92,7 @@ matrix:
|
|||||||
- libpgm-dev
|
- libpgm-dev
|
||||||
- libsodium-dev
|
- libsodium-dev
|
||||||
- libnss3-dev
|
- libnss3-dev
|
||||||
|
- libbsd-dev
|
||||||
- env: BUILD_TYPE=default CURVE=libsodium DRAFT=enabled
|
- env: BUILD_TYPE=default CURVE=libsodium DRAFT=enabled
|
||||||
os: osx
|
os: osx
|
||||||
- env: BUILD_TYPE=default CURVE=tweetnacl DRAFT=enabled ADDRESS_SANITIZER=enabled
|
- env: BUILD_TYPE=default CURVE=tweetnacl DRAFT=enabled ADDRESS_SANITIZER=enabled
|
||||||
|
@ -29,6 +29,8 @@ include(TestZMQVersion)
|
|||||||
include(ZMQSourceRunChecks)
|
include(ZMQSourceRunChecks)
|
||||||
include(ZMQSupportMacros)
|
include(ZMQSupportMacros)
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
|
||||||
option(ENABLE_ASAN "Build with address sanitizer" OFF)
|
option(ENABLE_ASAN "Build with address sanitizer" OFF)
|
||||||
if(ENABLE_ASAN)
|
if(ENABLE_ASAN)
|
||||||
message(STATUS "Instrumenting with Address Sanitizer")
|
message(STATUS "Instrumenting with Address Sanitizer")
|
||||||
@ -120,17 +122,23 @@ if (NOT DISABLE_WS)
|
|||||||
set(ZMQ_HAVE_WS 1)
|
set(ZMQ_HAVE_WS 1)
|
||||||
|
|
||||||
if (WITH_NSS)
|
if (WITH_NSS)
|
||||||
find_package("NSS3")
|
pkg_check_modules(NSS3 "nss")
|
||||||
if (NSS3_FOUND)
|
if (NSS3_FOUND)
|
||||||
message(STATUS "Using NSS")
|
set(pkg_config_names_private "${pkg_config_names_private} nss")
|
||||||
include_directories(${NSS3_INCLUDE_DIRS})
|
|
||||||
set(pkg_config_names_private "${pkg_config_names_private} nss3")
|
|
||||||
set(pkg_config_libs_private "${pkg_config_libs_private} -lnss3")
|
|
||||||
set(ZMQ_USE_NSS 1)
|
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR
|
find_package("NSS3")
|
||||||
"nss is not installed. Install it, then run CMake again")
|
if (NSS3_FOUND)
|
||||||
|
set(pkg_config_libs_private "${pkg_config_libs_private} -lnss3")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"nss is not installed. Install it, then run CMake again")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
message(STATUS "Using NSS")
|
||||||
|
include_directories(${NSS3_INCLUDE_DIRS})
|
||||||
|
link_directories(${NSS3_LIBRARY_DIRS})
|
||||||
|
set(OPTIONAL_LIBRARIES ${NSS3_LIBRARIES})
|
||||||
|
set(ZMQ_USE_NSS 1)
|
||||||
else()
|
else()
|
||||||
list(APPEND sources ${CMAKE_CURRENT_SOURCE_DIR}/external/sha1/sha1.c ${CMAKE_CURRENT_SOURCE_DIR}/external/sha1/sha1.h)
|
list(APPEND sources ${CMAKE_CURRENT_SOURCE_DIR}/external/sha1/sha1.c ${CMAKE_CURRENT_SOURCE_DIR}/external/sha1/sha1.h)
|
||||||
message("Using builtin sha1")
|
message("Using builtin sha1")
|
||||||
@ -138,6 +146,24 @@ if (NOT DISABLE_WS)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT MSVC)
|
||||||
|
option(WITH_LIBBSD "Use libbsd instead of builtin strlcpy" ON)
|
||||||
|
if (WITH_LIBBSD)
|
||||||
|
pkg_check_modules(LIBBSD "libbsd")
|
||||||
|
if (LIBBSD_FOUND)
|
||||||
|
message(STATUS "Using libbsd")
|
||||||
|
include_directories(${LIBBSD_INCLUDE_DIRS})
|
||||||
|
set(pkg_config_names_private "${pkg_config_names_private} libbsd")
|
||||||
|
set(ZMQ_HAVE_LIBBSD 1)
|
||||||
|
link_directories(${LIBBSD_LIBRARY_DIRS})
|
||||||
|
set(OPTIONAL_LIBRARIES ${LIBBSD_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
if (NOT WITH_LIBBSD OR NOT LIBBSD_FOUND)
|
||||||
|
check_cxx_symbol_exists(strlcpy string.h ZMQ_HAVE_STRLCPY)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# Select curve encryption library, defaults to tweetnacl
|
# Select curve encryption library, defaults to tweetnacl
|
||||||
# To use libsodium instead, use --with-libsodium(must be installed)
|
# To use libsodium instead, use --with-libsodium(must be installed)
|
||||||
@ -460,7 +486,6 @@ if(NOT MSVC)
|
|||||||
check_cxx_symbol_exists(mkdtemp stdlib.h HAVE_MKDTEMP)
|
check_cxx_symbol_exists(mkdtemp stdlib.h HAVE_MKDTEMP)
|
||||||
check_cxx_symbol_exists(accept4 sys/socket.h HAVE_ACCEPT4)
|
check_cxx_symbol_exists(accept4 sys/socket.h HAVE_ACCEPT4)
|
||||||
check_cxx_symbol_exists(strnlen string.h HAVE_STRNLEN)
|
check_cxx_symbol_exists(strnlen string.h HAVE_STRNLEN)
|
||||||
check_cxx_symbol_exists(strlcpy string.h ZMQ_HAVE_STRLCPY)
|
|
||||||
else()
|
else()
|
||||||
set(HAVE_STRNLEN 1)
|
set(HAVE_STRNLEN 1)
|
||||||
endif()
|
endif()
|
||||||
@ -661,7 +686,6 @@ else()
|
|||||||
"Name pkg-config shall use to find openpgm libraries and include paths"
|
"Name pkg-config shall use to find openpgm libraries and include paths"
|
||||||
FORCE)
|
FORCE)
|
||||||
|
|
||||||
find_package(PkgConfig)
|
|
||||||
pkg_check_modules(OPENPGM ${OPENPGM_PKGCONFIG_NAME})
|
pkg_check_modules(OPENPGM ${OPENPGM_PKGCONFIG_NAME})
|
||||||
|
|
||||||
if(OPENPGM_FOUND)
|
if(OPENPGM_FOUND)
|
||||||
|
12
Makefile.am
12
Makefile.am
@ -344,11 +344,11 @@ if HAVE_VSCRIPT_COMPLEX
|
|||||||
src_libzmq_la_LDFLAGS += $(VSCRIPT_LDFLAGS),$(srcdir)/src/libzmq.vers
|
src_libzmq_la_LDFLAGS += $(VSCRIPT_LDFLAGS),$(srcdir)/src/libzmq.vers
|
||||||
endif
|
endif
|
||||||
|
|
||||||
src_libzmq_la_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS) $(LIBUNWIND_CFLAGS)
|
src_libzmq_la_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS) $(LIBUNWIND_CFLAGS) $(LIBBSD_CFLAGS)
|
||||||
src_libzmq_la_CFLAGS = $(CODE_COVERAGE_CFLAGS) $(LIBUNWIND_CFLAGS)
|
src_libzmq_la_CFLAGS = $(CODE_COVERAGE_CFLAGS) $(LIBUNWIND_CFLAGS) $(LIBBSD_CFLAGS)
|
||||||
src_libzmq_la_CXXFLAGS = @LIBZMQ_EXTRA_CXXFLAGS@ $(CODE_COVERAGE_CXXFLAGS) \
|
src_libzmq_la_CXXFLAGS = @LIBZMQ_EXTRA_CXXFLAGS@ $(CODE_COVERAGE_CXXFLAGS) \
|
||||||
$(LIBUNWIND_CFLAGS)
|
$(LIBUNWIND_CFLAGS) $(LIBBSD_CFLAGS)
|
||||||
src_libzmq_la_LIBADD = $(CODE_COVERAGE_LDFLAGS) $(LIBUNWIND_LIBS)
|
src_libzmq_la_LIBADD = $(CODE_COVERAGE_LDFLAGS) $(LIBUNWIND_LIBS) $(LIBBSD_LIBS)
|
||||||
|
|
||||||
if USE_NSS
|
if USE_NSS
|
||||||
src_libzmq_la_CPPFLAGS += ${NSS3_CFLAGS}
|
src_libzmq_la_CPPFLAGS += ${NSS3_CFLAGS}
|
||||||
@ -841,10 +841,10 @@ tests_test_security_curve_SOURCES += \
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
tests_test_security_curve_LDADD = \
|
tests_test_security_curve_LDADD = \
|
||||||
${TESTUTIL_LIBS} src/libzmq.la $(LIBUNWIND_LIBS)
|
${TESTUTIL_LIBS} src/libzmq.la $(LIBUNWIND_LIBS) $(LIBBSD_LIBS)
|
||||||
tests_test_security_curve_CPPFLAGS = \
|
tests_test_security_curve_CPPFLAGS = \
|
||||||
${TESTUTIL_CPPFLAGS} \
|
${TESTUTIL_CPPFLAGS} \
|
||||||
${LIBUNWIND_CFLAGS}
|
${LIBUNWIND_CFLAGS} ${LIBBSD_CFLAGS}
|
||||||
|
|
||||||
if USE_LIBSODIUM
|
if USE_LIBSODIUM
|
||||||
tests_test_security_curve_CPPFLAGS += \
|
tests_test_security_curve_CPPFLAGS += \
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
#cmakedefine HAVE_ACCEPT4
|
#cmakedefine HAVE_ACCEPT4
|
||||||
#cmakedefine HAVE_STRNLEN
|
#cmakedefine HAVE_STRNLEN
|
||||||
#cmakedefine ZMQ_HAVE_STRLCPY
|
#cmakedefine ZMQ_HAVE_STRLCPY
|
||||||
|
#cmakedefine ZMQ_HAVE_LIBBSD
|
||||||
|
|
||||||
#cmakedefine ZMQ_HAVE_IPC
|
#cmakedefine ZMQ_HAVE_IPC
|
||||||
|
|
||||||
|
52
configure.ac
52
configure.ac
@ -576,6 +576,7 @@ AC_ARG_WITH([tls],
|
|||||||
if test "x$enable_ws" != "xno"; then
|
if test "x$enable_ws" != "xno"; then
|
||||||
if test "x$with_tls" = "xyes"; then
|
if test "x$with_tls" = "xyes"; then
|
||||||
PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.1.4], [
|
PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.1.4], [
|
||||||
|
PKGCFG_NAMES_PRIVATE="$PKGCFG_NAMES_PRIVATE gnutls >= 3.1.4"
|
||||||
ws_crypto_library="gnutls"
|
ws_crypto_library="gnutls"
|
||||||
AC_DEFINE(ZMQ_USE_GNUTLS, [1], [Use GNUTLS for TLS])
|
AC_DEFINE(ZMQ_USE_GNUTLS, [1], [Use GNUTLS for TLS])
|
||||||
AC_DEFINE(ZMQ_HAVE_WS, [1], [Using websocket])
|
AC_DEFINE(ZMQ_HAVE_WS, [1], [Using websocket])
|
||||||
@ -751,19 +752,44 @@ AC_COMPILE_IFELSE(
|
|||||||
AC_MSG_RESULT([no])
|
AC_MSG_RESULT([no])
|
||||||
])
|
])
|
||||||
|
|
||||||
# string.h doesn't seem to be included by default in Fedora 30
|
AC_ARG_ENABLE([libbsd],
|
||||||
AC_MSG_CHECKING([whether strlcpy is available])
|
[AS_HELP_STRING([--enable-libbsd],
|
||||||
AC_COMPILE_IFELSE(
|
[enable libbsd [default=auto]])],
|
||||||
[AC_LANG_PROGRAM(
|
[enable_libbsd=$enableval],
|
||||||
[[#include <string.h>]],
|
[enable_libbsd="auto"])
|
||||||
[[char buf [100]; size_t bar = strlcpy (buf, "foo", 100); (void)bar; return 0;]])
|
|
||||||
],[
|
if test "x$enable_libbsd" != "xno"; then
|
||||||
AC_MSG_RESULT([yes])
|
PKG_CHECK_MODULES(LIBBSD, [libbsd],
|
||||||
AC_DEFINE(ZMQ_HAVE_STRLCPY, [1],
|
[
|
||||||
[strlcpy is available])
|
AC_DEFINE(ZMQ_HAVE_LIBBSD, 1, [The libbsd library is to be used])
|
||||||
],[
|
AC_SUBST([LIBBSD_CFLAGS])
|
||||||
AC_MSG_RESULT([no])
|
AC_SUBST([LIBBSD_LIBS])
|
||||||
])
|
PKGCFG_NAMES_PRIVATE="$PKGCFG_NAMES_PRIVATE libbsd"
|
||||||
|
found_libbsd="yes"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
found_libbsd="no"
|
||||||
|
if test "x$enable_libbsd" = "xyes"; then
|
||||||
|
AC_MSG_ERROR([Cannot find libbsd])
|
||||||
|
else
|
||||||
|
AC_MSG_WARN([Cannot find libbsd])
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
fi
|
||||||
|
if test "x$found_libbsd" != "xyes"; then
|
||||||
|
AC_MSG_CHECKING([whether strlcpy is available])
|
||||||
|
AC_COMPILE_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM(
|
||||||
|
[[#include <string.h>]],
|
||||||
|
[[char buf [100]; size_t bar = strlcpy (buf, "foo", 100); (void)bar; return 0;]])
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
AC_DEFINE(ZMQ_HAVE_STRLCPY, [1],
|
||||||
|
[strlcpy is available])
|
||||||
|
],[
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
])
|
||||||
|
fi
|
||||||
|
|
||||||
# pthread_setname is non-posix, and there are at least 4 different implementations
|
# pthread_setname is non-posix, and there are at least 4 different implementations
|
||||||
AC_MSG_CHECKING([whether signature of pthread_setname_np() has 1 argument])
|
AC_MSG_CHECKING([whether signature of pthread_setname_np() has 1 argument])
|
||||||
|
@ -11,6 +11,7 @@ Build-Depends: debhelper (>= 9),
|
|||||||
libunwind-dev | libunwind8-dev | libunwind7-dev,
|
libunwind-dev | libunwind8-dev | libunwind7-dev,
|
||||||
libnss3-dev,
|
libnss3-dev,
|
||||||
libgnutls28-dev | libgnutls-dev,
|
libgnutls28-dev | libgnutls-dev,
|
||||||
|
libbsd-dev,
|
||||||
pkg-config,
|
pkg-config,
|
||||||
asciidoc-base | asciidoc, xmlto,
|
asciidoc-base | asciidoc, xmlto,
|
||||||
Standards-Version: 3.9.8
|
Standards-Version: 3.9.8
|
||||||
@ -42,6 +43,7 @@ Depends: libzmq5 (= ${binary:Version}), ${misc:Depends},
|
|||||||
libunwind-dev | libunwind8-dev | libunwind7-dev,
|
libunwind-dev | libunwind8-dev | libunwind7-dev,
|
||||||
libnss3-dev,
|
libnss3-dev,
|
||||||
libgnutls28-dev | libgnutls-dev,
|
libgnutls28-dev | libgnutls-dev,
|
||||||
|
libbsd-dev,
|
||||||
Conflicts: libzmq-dev, libzmq5-dev
|
Conflicts: libzmq-dev, libzmq5-dev
|
||||||
Replaces: libzmq5-dev
|
Replaces: libzmq5-dev
|
||||||
Provides: libzmq5-dev
|
Provides: libzmq5-dev
|
||||||
|
@ -6,7 +6,7 @@ Version: 4.3.3
|
|||||||
Maintainer: libzmq Developers <zeromq-dev@lists.zeromq.org>
|
Maintainer: libzmq Developers <zeromq-dev@lists.zeromq.org>
|
||||||
Homepage: http://www.zeromq.org/
|
Homepage: http://www.zeromq.org/
|
||||||
Standards-Version: 3.9.8
|
Standards-Version: 3.9.8
|
||||||
Build-Depends: debhelper (>= 9), dh-autoreconf, libkrb5-dev, libpgm-dev, libnorm-dev, libsodium-dev, libunwind-dev | libunwind8-dev | libunwind7-dev, libnss3-dev, libgnutls28-dev | libgnutls-dev, pkg-config, asciidoc-base | asciidoc, xmlto
|
Build-Depends: debhelper (>= 9), dh-autoreconf, libkrb5-dev, libpgm-dev, libnorm-dev, libsodium-dev, libunwind-dev | libunwind8-dev | libunwind7-dev, libnss3-dev, libgnutls28-dev | libgnutls-dev, libbsd-dev, pkg-config, asciidoc-base | asciidoc, xmlto
|
||||||
Package-List:
|
Package-List:
|
||||||
libzmq3-dev deb libdevel optional arch=any
|
libzmq3-dev deb libdevel optional arch=any
|
||||||
libzmq5 deb libs optional arch=any
|
libzmq5 deb libs optional arch=any
|
||||||
|
@ -19,7 +19,7 @@ URL: http://www.zeromq.org/
|
|||||||
Source: http://download.zeromq.org/%{name}-%{version}.tar.gz
|
Source: http://download.zeromq.org/%{name}-%{version}.tar.gz
|
||||||
Prefix: %{_prefix}
|
Prefix: %{_prefix}
|
||||||
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
||||||
BuildRequires: autoconf automake libtool glib2-devel
|
BuildRequires: autoconf automake libtool glib2-devel libbsd-devel
|
||||||
%if ! (0%{?fedora} > 12 || 0%{?rhel} > 5)
|
%if ! (0%{?fedora} > 12 || 0%{?rhel} > 5)
|
||||||
BuildRequires: e2fsprogs-devel
|
BuildRequires: e2fsprogs-devel
|
||||||
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
|
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
|
||||||
|
@ -74,7 +74,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#ifdef ZMQ_HAVE_WINDOWS
|
#ifdef ZMQ_HAVE_WINDOWS
|
||||||
#define strcasecmp _stricmp
|
#define strcasecmp _stricmp
|
||||||
#else
|
#else
|
||||||
#ifndef ZMQ_HAVE_STRLCPY
|
#ifdef ZMQ_HAVE_LIBBSD
|
||||||
|
#include <bsd/string.h>
|
||||||
|
#elif !defined(ZMQ_HAVE_STRLCPY)
|
||||||
static size_t strlcpy (char *dest_, const char *src_, const size_t dest_size_)
|
static size_t strlcpy (char *dest_, const char *src_, const size_t dest_size_)
|
||||||
{
|
{
|
||||||
size_t remain = dest_size_;
|
size_t remain = dest_size_;
|
||||||
@ -146,8 +148,11 @@ void zmq::ws_engine_t::start_ws_handshake ()
|
|||||||
else if (_options.mechanism == ZMQ_CURVE)
|
else if (_options.mechanism == ZMQ_CURVE)
|
||||||
protocol = "ZWS2.0/CURVE";
|
protocol = "ZWS2.0/CURVE";
|
||||||
#endif
|
#endif
|
||||||
else
|
else {
|
||||||
|
// Avoid unitialized variable error breaking UWP build
|
||||||
|
protocol = "";
|
||||||
assert (false);
|
assert (false);
|
||||||
|
}
|
||||||
|
|
||||||
unsigned char nonce[16];
|
unsigned char nonce[16];
|
||||||
int *p = reinterpret_cast<int *> (nonce);
|
int *p = reinterpret_cast<int *> (nonce);
|
||||||
|
@ -101,7 +101,7 @@ int main (void)
|
|||||||
setup_test_environment ();
|
setup_test_environment ();
|
||||||
|
|
||||||
UNITY_BEGIN ();
|
UNITY_BEGIN ();
|
||||||
#if !defined(ZMQ_HAVE_WINDOWS) && !defined(ZMQ_HAVE_GNU)
|
#if defined(ZMQ_HAVE_IPC) && !defined(ZMQ_HAVE_GNU)
|
||||||
RUN_TEST (test_reconnect_ivl_ipc);
|
RUN_TEST (test_reconnect_ivl_ipc);
|
||||||
#endif
|
#endif
|
||||||
RUN_TEST (test_reconnect_ivl_tcp_ipv4);
|
RUN_TEST (test_reconnect_ivl_tcp_ipv4);
|
||||||
|
Loading…
Reference in New Issue
Block a user