summaryrefslogtreecommitdiff
path: root/src/options.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2010-02-19 15:24:43 +0100
committerMartin Sustrik <sustrik@250bpm.com>2010-02-19 15:24:43 +0100
commit75f571c8844231f4172f131e1dd6ba2348eb54e5 (patch)
tree035106d6f65e69613a16470f9188d3aabab51179 /src/options.cpp
parentb9caa319e279cd8cd367e0a64308b9e80c4ead3d (diff)
Multi-hop REQ/REP, part XII., generate unique identities for anonymous connections
Diffstat (limited to 'src/options.cpp')
-rw-r--r--src/options.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/options.cpp b/src/options.cpp
index b77af24..f78d8de 100644
--- a/src/options.cpp
+++ b/src/options.cpp
@@ -77,6 +77,15 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
return 0;
case ZMQ_IDENTITY:
+
+ // Empty identity is invalid as well as identity longer than
+ // 255 bytes. Identity starting with binary zero is invalid
+ // as these are used for auto-generated identities.
+ if (optvallen_ < 1 || optvallen_ > 255 ||
+ *((const unsigned char*) optval_) == 0) {
+ errno = EINVAL;
+ return -1;
+ }
identity.assign ((const unsigned char*) optval_, optvallen_);
return 0;