Merge pull request #3705 from somdoron/ws_mechanism

problem: zero-sized messages cause assertion when glibc assertion are on
This commit is contained in:
Luca Boccassi 2019-10-07 08:37:32 +01:00 committed by GitHub
commit de845bd021
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 (