From 2fb04c101823bbecc31ce2f9d253eeafbba1b92f Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sat, 22 Aug 2020 17:00:57 +0100 Subject: [PATCH] Problem: ZMQ_METADATA setsockopt ignores length and assumes nUL-terminated string Solution: use length too --- src/options.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/options.cpp b/src/options.cpp index a5c61f24..3edc5fcd 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -761,7 +761,8 @@ int zmq::options_t::setsockopt (int option_, case ZMQ_METADATA: if (optvallen_ > 0 && !is_int) { - const std::string s (static_cast (optval_)); + const std::string s (static_cast (optval_), + optvallen_); const size_t pos = s.find (':'); if (pos != std::string::npos && pos != 0 && pos != s.length () - 1) {