Unverified Commit de845bd0 authored by Luca Boccassi's avatar Luca Boccassi Committed by GitHub

Merge pull request #3705 from somdoron/ws_mechanism

problem: zero-sized messages cause assertion when glibc assertion are on
parents 539718f3 9b15658e
......@@ -70,8 +70,9 @@ int zmq::curve_mechanism_base_t::encode (msg_t *msg_)
message_plaintext[crypto_box_ZEROBYTES] = flags;
// this is copying the data from insecure memory, so there is no point in
// using secure_allocator_t for message_plaintext
memcpy (&message_plaintext[crypto_box_ZEROBYTES + 1], msg_->data (),
msg_->size ());
if (msg_->size () > 0)
memcpy (&message_plaintext[crypto_box_ZEROBYTES + 1], msg_->data (),
msg_->size ());
std::vector<uint8_t> message_box (mlen);
......@@ -160,8 +161,9 @@ int zmq::curve_mechanism_base_t::decode (msg_t *msg_)
// this is copying the data to insecure memory, so there is no point in
// using secure_allocator_t for message_plaintext
memcpy (msg_->data (), &message_plaintext[crypto_box_ZEROBYTES + 1],
msg_->size ());
if (msg_->size () > 0)
memcpy (msg_->data (), &message_plaintext[crypto_box_ZEROBYTES + 1],
msg_->size ());
} else {
// CURVE I : connection key used for MESSAGE is wrong
session->get_socket ()->event_handshake_failed_protocol (
......
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