mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-28 03:20:13 +01:00
ZMQ_MAXMSGSIZE option added
The new option allows user to guard against peers sending oversized messages. Connection to peer sending oversized message is dropped. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
This commit is contained in:
@@ -39,6 +39,7 @@ zmq::options_t::options_t () :
|
||||
reconnect_ivl (100),
|
||||
reconnect_ivl_max (0),
|
||||
backlog (100),
|
||||
maxmsgsize (-1),
|
||||
requires_in (false),
|
||||
requires_out (false),
|
||||
immediate_connect (true)
|
||||
@@ -182,6 +183,14 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
|
||||
backlog = *((int*) optval_);
|
||||
return 0;
|
||||
|
||||
case ZMQ_MAXMSGSIZE:
|
||||
if (optvallen_ != sizeof (int64_t)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
maxmsgsize = *((int64_t*) optval_);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
errno = EINVAL;
|
||||
@@ -328,6 +337,15 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
|
||||
*optvallen_ = sizeof (int);
|
||||
return 0;
|
||||
|
||||
case ZMQ_MAXMSGSIZE:
|
||||
if (*optvallen_ < sizeof (int64_t)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
*((int64_t*) optval_) = maxmsgsize;
|
||||
*optvallen_ = sizeof (int64_t);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
errno = EINVAL;
|
||||
|
||||
Reference in New Issue
Block a user