mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-26 10:32:58 +01:00
Fixed wrong buffer end detection in v2_decoder.
zero-copy msg_t::init cannot be used when the message exceeds either the buffer end or the last received byte. To detect this, the buffer is now resized to the numnber of received bytes.
This commit is contained in:
@@ -295,6 +295,7 @@ void zmq::stream_engine_t::in_event ()
|
||||
decoder->get_buffer (&inpos, &bufsize);
|
||||
|
||||
const int rc = tcp_read (s, inpos, bufsize);
|
||||
|
||||
if (rc == 0) {
|
||||
error (connection_error);
|
||||
return;
|
||||
@@ -307,6 +308,8 @@ void zmq::stream_engine_t::in_event ()
|
||||
|
||||
// Adjust input size
|
||||
insize = static_cast <size_t> (rc);
|
||||
// Adjust buffer size to received bytes
|
||||
decoder->resize_buffer(insize);
|
||||
}
|
||||
|
||||
int rc = 0;
|
||||
|
||||
Reference in New Issue
Block a user