package/dhcp/S80dhcp-server: allow empty INTERFACES
[buildroot-gz.git] / package / zeromq / 0003-Problem-return-code-of-sodium_init-is-not-checked.patch
blobfcdbc9cde1289b92f1af049d9c36fd1c797c6424
1 From 479db2113643e459c11db392e0fefd6400657c9e Mon Sep 17 00:00:00 2001
2 From: Constantin Rack <constantin@rack.li>
3 Date: Sat, 8 Nov 2014 10:50:17 +0100
4 Subject: [PATCH] Problem: return code of sodium_init() is not checked.
6 There are two todo comments in curve_client.cpp and curve_server.cpp that suggest
7 checking the return code of sodium_init() call. sodium_init() returns -1 on error,
8 0 on success and 1 if it has been called before and is already initalized:
9 https://github.com/jedisct1/libsodium/blob/master/src/libsodium/sodium/core.c
11 Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
12 ---
13 Status: Upstream
15 diff --git a/src/curve_client.cpp b/src/curve_client.cpp
16 index 6019c54..77fc420 100644
17 --- a/src/curve_client.cpp
18 +++ b/src/curve_client.cpp
19 @@ -38,6 +38,7 @@ zmq::curve_client_t::curve_client_t (const options_t &options_) :
20 cn_peer_nonce(1),
21 sync()
23 + int rc;
24 memcpy (public_key, options_.curve_public_key, crypto_box_PUBLICKEYBYTES);
25 memcpy (secret_key, options_.curve_secret_key, crypto_box_SECRETKEYBYTES);
26 memcpy (server_key, options_.curve_server_key, crypto_box_PUBLICKEYBYTES);
27 @@ -47,12 +48,12 @@ zmq::curve_client_t::curve_client_t (const options_t &options_) :
28 unsigned char tmpbytes[4];
29 randombytes(tmpbytes, 4);
30 #else
31 - // todo check return code
32 - sodium_init();
33 + rc = sodium_init ();
34 + zmq_assert (rc != -1);
35 #endif
37 // Generate short-term key pair
38 - const int rc = crypto_box_keypair (cn_public, cn_secret);
39 + rc = crypto_box_keypair (cn_public, cn_secret);
40 zmq_assert (rc == 0);
43 diff --git a/src/curve_server.cpp b/src/curve_server.cpp
44 index a3c4243..22c32d6 100644
45 --- a/src/curve_server.cpp
46 +++ b/src/curve_server.cpp
47 @@ -42,6 +42,7 @@ zmq::curve_server_t::curve_server_t (session_base_t *session_,
48 cn_peer_nonce(1),
49 sync()
51 + int rc;
52 // Fetch our secret key from socket options
53 memcpy (secret_key, options_.curve_secret_key, crypto_box_SECRETKEYBYTES);
54 scoped_lock_t lock (sync);
55 @@ -50,12 +51,12 @@ zmq::curve_server_t::curve_server_t (session_base_t *session_,
56 unsigned char tmpbytes[4];
57 randombytes(tmpbytes, 4);
58 #else
59 - // todo check return code
60 - sodium_init();
61 + rc = sodium_init ();
62 + zmq_assert (rc != -1);
63 #endif
65 // Generate short-term key pair
66 - const int rc = crypto_box_keypair (cn_public, cn_secret);
67 + rc = crypto_box_keypair (cn_public, cn_secret);
68 zmq_assert (rc == 0);
71 --
72 2.4.10