mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-17 16:43:58 +00:00
Clean up after using randombytes from libsodium
When Curve authentication is used, libsodium opens a file descriptor to /dev/urandom to generate random bytes. When the ZMQ context terminates, it should ensure that file gets closed.
This commit is contained in:
parent
ce75ea7448
commit
16b2db6062
10
src/ctx.cpp
10
src/ctx.cpp
@ -35,6 +35,10 @@
|
|||||||
#include "err.hpp"
|
#include "err.hpp"
|
||||||
#include "msg.hpp"
|
#include "msg.hpp"
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBSODIUM
|
||||||
|
#include <sodium.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ZMQ_CTX_TAG_VALUE_GOOD 0xabadcafe
|
#define ZMQ_CTX_TAG_VALUE_GOOD 0xabadcafe
|
||||||
#define ZMQ_CTX_TAG_VALUE_BAD 0xdeadbeef
|
#define ZMQ_CTX_TAG_VALUE_BAD 0xdeadbeef
|
||||||
|
|
||||||
@ -89,6 +93,12 @@ zmq::ctx_t::~ctx_t ()
|
|||||||
// corresponding io_thread/socket objects.
|
// corresponding io_thread/socket objects.
|
||||||
free (slots);
|
free (slots);
|
||||||
|
|
||||||
|
// If we've done any Curve encryption, we may have a file handle
|
||||||
|
// to /dev/urandom open that needs to be cleaned up.
|
||||||
|
#ifdef HAVE_LIBSODIUM
|
||||||
|
randombytes_close();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Remove the tag, so that the object is considered dead.
|
// Remove the tag, so that the object is considered dead.
|
||||||
tag = ZMQ_CTX_TAG_VALUE_BAD;
|
tag = ZMQ_CTX_TAG_VALUE_BAD;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user