mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-15 18:38:00 +08:00
Merge pull request #69 from maytechnet/master
Problem: return code of sodium_init() is not checked.
This commit is contained in:
commit
a75b7543e8
@ -48,6 +48,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);
|
||||
@ -57,12 +58,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);
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,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);
|
||||
@ -60,12 +61,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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user