mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-30 05:29:43 +01:00
Fixed overwrite in zmq_getsockopt
On ZMQ_CURVE_xxxKEY fetches, would return 41 bytes into caller's 40-byte buffer. Now these fetches only return 41 bytes if the caller explicitly provides a 41-byte buffer (i.e. the option size is 41).
This commit is contained in:
@@ -590,7 +590,7 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
if (*optvallen_ == CURVE_KEYSIZE_Z85) {
|
||||
if (*optvallen_ == CURVE_KEYSIZE_Z85 + 1) {
|
||||
Z85_encode ((char *) optval_, curve_public_key, CURVE_KEYSIZE);
|
||||
return 0;
|
||||
}
|
||||
@@ -602,7 +602,7 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
if (*optvallen_ == CURVE_KEYSIZE_Z85) {
|
||||
if (*optvallen_ == CURVE_KEYSIZE_Z85 + 1) {
|
||||
Z85_encode ((char *) optval_, curve_secret_key, CURVE_KEYSIZE);
|
||||
return 0;
|
||||
}
|
||||
@@ -614,7 +614,7 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
if (*optvallen_ == CURVE_KEYSIZE_Z85) {
|
||||
if (*optvallen_ == CURVE_KEYSIZE_Z85 + 1) {
|
||||
Z85_encode ((char *) optval_, curve_server_key, CURVE_KEYSIZE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user