Unverified Commit 89e5f15a authored by Luca Boccassi's avatar Luca Boccassi Committed by GitHub

Merge pull request #3149 from sigiesec/analyze

Few more code style fixes
parents 6bfa91f1 67b602fe
......@@ -28,6 +28,19 @@ env:
matrix:
include:
- if: type = cron OR (branch =~ analyze$ AND type = push)
env: BUILD_TYPE=cmake CLANG_TIDY=/usr/bin/clang-tidy-6.0 CC=clang-6.0 CXX=clang++-6.0
os: linux
compiler: clang
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
packages:
- clang-6.0
- clang-tools-6.0
- clang-tidy-6.0
- env: BUILD_TYPE=default CURVE=tweetnacl IPv6=ON
os: linux
dist: precise
......@@ -94,19 +107,6 @@ matrix:
- llvm-toolchain-trusty-5.0
packages:
- clang-5.0
- if: type = cron OR (branch =~ analyze$ AND type = push)
env: BUILD_TYPE=cmake CLANG_TIDY=/usr/bin/clang-tidy-6.0 CC=clang-6.0 CXX=clang++-6.0
os: linux
compiler: clang
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
packages:
- clang-6.0
- clang-tools-6.0
- clang-tidy-6.0
- env: BUILD_TYPE=default POLLER=poll
os: linux
- env: BUILD_TYPE=default POLLER=select
......
......@@ -51,6 +51,7 @@ CMAKE_PREFIXES=()
MAKE_PREFIXES=()
PARALLEL_MAKE_OPT="-j5"
if [ -n "$CLANG_TIDY" ] ; then
CMAKE_OPTS+=("-DCMAKE_BUILD_TYPE=Debug") # do a debug build to avoid unused variable warnings with assertions, and to speed up build
CMAKE_OPTS+=("-DCMAKE_CXX_CLANG_TIDY:STRING=${CLANG_TIDY}")
if [ -n ${SONARCLOUD_BUILD_WRAPPER_PATH} ] ; then
MAKE_PREFIXES+=("${SONARCLOUD_BUILD_WRAPPER_PATH}build-wrapper-linux-x86-64")
......
......@@ -120,7 +120,7 @@ int zmq::plain_server_t::process_hello (msg_t *msg_)
size_t bytes_left = msg_->size ();
if (bytes_left < hello_prefix_len
|| memcmp (ptr, hello_prefix, hello_prefix_len)) {
|| memcmp (ptr, hello_prefix, hello_prefix_len) != 0) {
session->get_socket ()->event_handshake_failed_protocol (
session->get_endpoint (), ZMQ_PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND);
errno = EPROTO;
......@@ -138,7 +138,7 @@ int zmq::plain_server_t::process_hello (msg_t *msg_)
return -1;
}
const uint8_t username_length = *ptr++;
bytes_left -= 1;
bytes_left -= sizeof (username_length);
if (bytes_left < username_length) {
// 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++;
bytes_left -= 1;
if (bytes_left < password_length) {
// PLAIN I: invalid PLAIN client, sent malformed password
bytes_left -= sizeof (password_length);
if (bytes_left != password_length) {
// PLAIN I: invalid PLAIN client, sent malformed password or
// extraneous data
session->get_socket ()->event_handshake_failed_protocol (
session->get_endpoint (),
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);
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.
rc = session->zap_connect ();
......@@ -214,7 +205,7 @@ int zmq::plain_server_t::process_initiate (msg_t *msg_)
const size_t bytes_left = msg_->size ();
if (bytes_left < initiate_prefix_len
|| memcmp (ptr, initiate_prefix, initiate_prefix_len)) {
|| memcmp (ptr, initiate_prefix, initiate_prefix_len) != 0) {
session->get_socket ()->event_handshake_failed_protocol (
session->get_endpoint (), ZMQ_PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND);
errno = EPROTO;
......
......@@ -361,6 +361,8 @@ void zmq::udp_engine_t::out_event ()
if (rc == 0) {
msg_t body_msg;
rc = _session->pull_msg (&body_msg);
// TODO rc is not checked here. We seem to assume rc == 0. An
// assertion should be added.
const size_t group_size = group_msg.size ();
const size_t body_size = body_msg.size ();
......
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