Problem: setsockopt of CURVE key ignores parameter length

Solution: create std::string using length to avoid overflow
This commit is contained in:
Luca Boccassi 2020-08-23 13:47:07 +01:00
parent 8cc56d9f0f
commit 97f8274129

View File

@ -276,13 +276,16 @@ int zmq::options_t::set_curve_key (uint8_t *destination_,
mechanism = ZMQ_CURVE; mechanism = ZMQ_CURVE;
return 0; return 0;
case CURVE_KEYSIZE_Z85 + 1: case CURVE_KEYSIZE_Z85 + 1: {
if (zmq_z85_decode (destination_, const std::string s (static_cast<const char *> (optval_),
reinterpret_cast<const char *> (optval_))) { optvallen_);
if (zmq_z85_decode (destination_, s.c_str ())) {
mechanism = ZMQ_CURVE; mechanism = ZMQ_CURVE;
return 0; return 0;
} }
break; break;
}
case CURVE_KEYSIZE_Z85: case CURVE_KEYSIZE_Z85:
char z85_key[CURVE_KEYSIZE_Z85 + 1]; char z85_key[CURVE_KEYSIZE_Z85 + 1];