From 310b7e24d24ae9eeb1c86ec8f026e1c2919195c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Sat, 7 Nov 2015 18:13:45 +0100 Subject: [PATCH] zeromq: add patch to fix build --- pkgs/development/libraries/zeromq/4.x.nix | 3 + .../libraries/zeromq/sodium_warning.patch | 70 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 pkgs/development/libraries/zeromq/sodium_warning.patch diff --git a/pkgs/development/libraries/zeromq/4.x.nix b/pkgs/development/libraries/zeromq/4.x.nix index de91ac50428f..4cac67a2da84 100644 --- a/pkgs/development/libraries/zeromq/4.x.nix +++ b/pkgs/development/libraries/zeromq/4.x.nix @@ -11,6 +11,9 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ pkgconfig ]; buildInputs = [ libuuid libsodium ]; + # https://github.com/zeromq/libzmq/commit/479db2113643e459c11db392e0fefd6400657c9e + patches = [ ./sodium_warning.patch ]; + meta = with stdenv.lib; { branch = "4"; homepage = "http://www.zeromq.org"; diff --git a/pkgs/development/libraries/zeromq/sodium_warning.patch b/pkgs/development/libraries/zeromq/sodium_warning.patch new file mode 100644 index 000000000000..4b84fd7edf42 --- /dev/null +++ b/pkgs/development/libraries/zeromq/sodium_warning.patch @@ -0,0 +1,70 @@ +From 479db2113643e459c11db392e0fefd6400657c9e Mon Sep 17 00:00:00 2001 +From: Constantin Rack +Date: Sat, 8 Nov 2014 10:50:17 +0100 +Subject: [PATCH] Problem: return code of sodium_init() is not checked. + +There are two todo comments in curve_client.cpp and curve_server.cpp that suggest +checking the return code of sodium_init() call. sodium_init() returns -1 on error, +0 on success and 1 if it has been called before and is already initalized: +https://github.com/jedisct1/libsodium/blob/master/src/libsodium/sodium/core.c +--- + src/curve_client.cpp | 7 ++++--- + src/curve_server.cpp | 7 ++++--- + 2 files changed, 8 insertions(+), 6 deletions(-) + +diff --git a/src/curve_client.cpp b/src/curve_client.cpp +index 6019c54..77fc420 100644 +--- a/src/curve_client.cpp ++++ b/src/curve_client.cpp +@@ -38,6 +38,7 @@ zmq::curve_client_t::curve_client_t (const options_t &options_) : + cn_peer_nonce(1), + sync() + { ++ int rc; + memcpy (public_key, options_.curve_public_key, crypto_box_PUBLICKEYBYTES); + memcpy (secret_key, options_.curve_secret_key, crypto_box_SECRETKEYBYTES); + memcpy (server_key, options_.curve_server_key, crypto_box_PUBLICKEYBYTES); +@@ -47,12 +48,12 @@ zmq::curve_client_t::curve_client_t (const options_t &options_) : + unsigned char tmpbytes[4]; + randombytes(tmpbytes, 4); + #else +- // todo check return code +- sodium_init(); ++ rc = sodium_init (); ++ zmq_assert (rc != -1); + #endif + + // Generate short-term key pair +- const int rc = crypto_box_keypair (cn_public, cn_secret); ++ rc = crypto_box_keypair (cn_public, cn_secret); + zmq_assert (rc == 0); + } + +diff --git a/src/curve_server.cpp b/src/curve_server.cpp +index a3c4243..22c32d6 100644 +--- a/src/curve_server.cpp ++++ b/src/curve_server.cpp +@@ -42,6 +42,7 @@ zmq::curve_server_t::curve_server_t (session_base_t *session_, + cn_peer_nonce(1), + sync() + { ++ int rc; + // Fetch our secret key from socket options + memcpy (secret_key, options_.curve_secret_key, crypto_box_SECRETKEYBYTES); + scoped_lock_t lock (sync); +@@ -50,12 +51,12 @@ zmq::curve_server_t::curve_server_t (session_base_t *session_, + unsigned char tmpbytes[4]; + randombytes(tmpbytes, 4); + #else +- // todo check return code +- sodium_init(); ++ rc = sodium_init (); ++ zmq_assert (rc != -1); + #endif + + // Generate short-term key pair +- const int rc = crypto_box_keypair (cn_public, cn_secret); ++ rc = crypto_box_keypair (cn_public, cn_secret); + zmq_assert (rc == 0); + } +