diff options
Diffstat (limited to 'src/options.cpp')
-rw-r--r-- | src/options.cpp | 9 |
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; |