mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-28 19:52:00 +01:00
Check message syntax in REQ asynchronously
This patch adds support for checking messages as they arrive (as opposed to when they are recv'd by the user) and drop the connection if they are malformed. It also uses this new feature to check for validity of inbound messages in REQ socket. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
This commit is contained in:
20
src/req.cpp
20
src/req.cpp
@@ -158,3 +158,23 @@ zmq::req_session_t::~req_session_t ()
|
||||
{
|
||||
}
|
||||
|
||||
int zmq::req_session_t::write (msg_t *msg_)
|
||||
{
|
||||
if (state == request_id) {
|
||||
if (msg_->flags () == msg_t::label && msg_->size () == 4) {
|
||||
state = body;
|
||||
return xreq_session_t::write (msg_);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (msg_->flags () == msg_t::more)
|
||||
return xreq_session_t::write (msg_);
|
||||
if (msg_->flags () == 0) {
|
||||
state = request_id;
|
||||
return xreq_session_t::write (msg_);
|
||||
}
|
||||
}
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user