mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-10 16:06:09 +00:00
Problem: unused values stored to variable, duplicated code
Solution: remove duplicated and redundant code
This commit is contained in:
parent
ee4cdf8bf0
commit
c2ba553d87
@ -138,7 +138,7 @@ int zmq::plain_server_t::process_hello (msg_t *msg_)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
const uint8_t username_length = *ptr++;
|
const uint8_t username_length = *ptr++;
|
||||||
bytes_left -= 1;
|
bytes_left -= sizeof (username_length);
|
||||||
|
|
||||||
if (bytes_left < username_length) {
|
if (bytes_left < username_length) {
|
||||||
// PLAIN I: invalid PLAIN client, sent malformed username
|
// PLAIN I: invalid PLAIN client, sent malformed username
|
||||||
@ -161,9 +161,10 @@ int zmq::plain_server_t::process_hello (msg_t *msg_)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t password_length = *ptr++;
|
const uint8_t password_length = *ptr++;
|
||||||
bytes_left -= 1;
|
bytes_left -= sizeof (password_length);
|
||||||
if (bytes_left < password_length) {
|
if (bytes_left != password_length) {
|
||||||
// PLAIN I: invalid PLAIN client, sent malformed password
|
// PLAIN I: invalid PLAIN client, sent malformed password or
|
||||||
|
// extraneous data
|
||||||
session->get_socket ()->event_handshake_failed_protocol (
|
session->get_socket ()->event_handshake_failed_protocol (
|
||||||
session->get_endpoint (),
|
session->get_endpoint (),
|
||||||
ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_HELLO);
|
ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_HELLO);
|
||||||
@ -172,16 +173,6 @@ int zmq::plain_server_t::process_hello (msg_t *msg_)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const std::string password = std::string (ptr, password_length);
|
const std::string password = std::string (ptr, password_length);
|
||||||
ptr += password_length;
|
|
||||||
bytes_left -= password_length;
|
|
||||||
if (bytes_left > 0) {
|
|
||||||
// PLAIN I: invalid PLAIN client, sent extraneous data
|
|
||||||
session->get_socket ()->event_handshake_failed_protocol (
|
|
||||||
session->get_endpoint (),
|
|
||||||
ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_HELLO);
|
|
||||||
errno = EPROTO;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use ZAP protocol (RFC 27) to authenticate the user.
|
// Use ZAP protocol (RFC 27) to authenticate the user.
|
||||||
rc = session->zap_connect ();
|
rc = session->zap_connect ();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user