Commit 6cf120ea authored by Min RK's avatar Min RK

reject old ZMTP connections if auth enabled

auth mechanisms were only enabled when ZMTP handshake
is latest version, meaning that connections from old sockets
would skip authentication altogether
parent c35c0ca1
......@@ -534,6 +534,12 @@ bool zmq::stream_engine_t::handshake ()
// Is the peer using ZMTP/1.0 with no revision number?
// If so, we send and receive rest of identity message
if (greeting_recv [0] != 0xff || !(greeting_recv [9] & 0x01)) {
if (session->zap_connect () == 0) {
// reject ZMTP 1.0 connections if ZAP is enabled
error (protocol_error);
return false;
}
encoder = new (std::nothrow) v1_encoder_t (out_batch_size);
alloc_assert (encoder);
......@@ -575,6 +581,12 @@ bool zmq::stream_engine_t::handshake ()
}
else
if (greeting_recv [revision_pos] == ZMTP_1_0) {
if (session->zap_connect () == 0) {
// reject ZMTP 1.0 connections if ZAP is enabled
error (protocol_error);
return false;
}
encoder = new (std::nothrow) v1_encoder_t (
out_batch_size);
alloc_assert (encoder);
......@@ -585,6 +597,12 @@ bool zmq::stream_engine_t::handshake ()
}
else
if (greeting_recv [revision_pos] == ZMTP_2_0) {
if (session->zap_connect () == 0) {
// reject ZMTP 2.0 connections if ZAP is enabled
error (protocol_error);
return false;
}
encoder = new (std::nothrow) v2_encoder_t (out_batch_size);
alloc_assert (encoder);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment