From 75f571c8844231f4172f131e1dd6ba2348eb54e5 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Fri, 19 Feb 2010 15:24:43 +0100 Subject: Multi-hop REQ/REP, part XII., generate unique identities for anonymous connections --- src/options.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/options.cpp') 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; -- cgit v1.2.3