mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-31 01:43:02 +08:00
Return EINVAL when trying to use CURVE without libsodium
This commit is contained in:
parent
357a9c45fb
commit
76df045950
@ -285,11 +285,9 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// If libsodium isn't installed, these options provoke EINVAL
|
||||||
|
# ifdef HAVE_LIBSODIUM
|
||||||
case ZMQ_CURVE_SERVER:
|
case ZMQ_CURVE_SERVER:
|
||||||
# ifndef HAVE_LIBSODIUM
|
|
||||||
puts ("E: libzmq was not built using libsodium, CURVE not available");
|
|
||||||
assert (false);
|
|
||||||
# endif
|
|
||||||
if (is_int && (value == 0 || value == 1)) {
|
if (is_int && (value == 0 || value == 1)) {
|
||||||
as_server = value;
|
as_server = value;
|
||||||
mechanism = value? ZMQ_CURVE: ZMQ_NULL;
|
mechanism = value? ZMQ_CURVE: ZMQ_NULL;
|
||||||
@ -298,10 +296,6 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ZMQ_CURVE_PUBLICKEY:
|
case ZMQ_CURVE_PUBLICKEY:
|
||||||
# ifndef HAVE_LIBSODIUM
|
|
||||||
puts ("E: libzmq was not built using libsodium, CURVE not available");
|
|
||||||
assert (false);
|
|
||||||
# endif
|
|
||||||
if (optvallen_ == CURVE_KEYSIZE) {
|
if (optvallen_ == CURVE_KEYSIZE) {
|
||||||
memcpy (curve_public_key, optval_, CURVE_KEYSIZE);
|
memcpy (curve_public_key, optval_, CURVE_KEYSIZE);
|
||||||
mechanism = ZMQ_CURVE;
|
mechanism = ZMQ_CURVE;
|
||||||
@ -310,10 +304,6 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ZMQ_CURVE_SECRETKEY:
|
case ZMQ_CURVE_SECRETKEY:
|
||||||
# ifndef HAVE_LIBSODIUM
|
|
||||||
puts ("E: libzmq was not built using libsodium, CURVE not available");
|
|
||||||
assert (false);
|
|
||||||
# endif
|
|
||||||
if (optvallen_ == CURVE_KEYSIZE) {
|
if (optvallen_ == CURVE_KEYSIZE) {
|
||||||
memcpy (curve_secret_key, optval_, CURVE_KEYSIZE);
|
memcpy (curve_secret_key, optval_, CURVE_KEYSIZE);
|
||||||
mechanism = ZMQ_CURVE;
|
mechanism = ZMQ_CURVE;
|
||||||
@ -322,10 +312,6 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ZMQ_CURVE_SERVERKEY:
|
case ZMQ_CURVE_SERVERKEY:
|
||||||
# ifndef HAVE_LIBSODIUM
|
|
||||||
puts ("E: libzmq was not built using libsodium, CURVE not available");
|
|
||||||
assert (false);
|
|
||||||
# endif
|
|
||||||
if (optvallen_ == CURVE_KEYSIZE) {
|
if (optvallen_ == CURVE_KEYSIZE) {
|
||||||
memcpy (curve_server_key, optval_, CURVE_KEYSIZE);
|
memcpy (curve_server_key, optval_, CURVE_KEYSIZE);
|
||||||
as_server = 0;
|
as_server = 0;
|
||||||
@ -333,9 +319,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
# endif
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
@ -555,6 +539,8 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// If libsodium isn't installed, these options provoke EINVAL
|
||||||
|
# ifdef HAVE_LIBSODIUM
|
||||||
case ZMQ_CURVE_SERVER:
|
case ZMQ_CURVE_SERVER:
|
||||||
if (is_int) {
|
if (is_int) {
|
||||||
*value = as_server && mechanism == ZMQ_CURVE;
|
*value = as_server && mechanism == ZMQ_CURVE;
|
||||||
@ -582,6 +568,7 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user