Merge pull request #4011 from bluca/fuzzers

Problem: use-after-free in WS
This commit is contained in:
Doron Somech 2020-08-15 17:06:58 +03:00 committed by GitHub
commit d280c44fe0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -344,8 +344,14 @@ void zmq::stream_engine_base_t::out_event ()
_outsize = _encoder->encode (&_outpos, 0); _outsize = _encoder->encode (&_outpos, 0);
while (_outsize < static_cast<size_t> (_options.out_batch_size)) { while (_outsize < static_cast<size_t> (_options.out_batch_size)) {
if ((this->*_next_msg) (&_tx_msg) == -1) if ((this->*_next_msg) (&_tx_msg) == -1) {
break; // ws_engine can cause an engine error and delete it, so
// bail out immediately to avoid use-after-free
if (errno == ECONNRESET)
return;
else
break;
}
_encoder->load_msg (&_tx_msg); _encoder->load_msg (&_tx_msg);
unsigned char *bufptr = _outpos + _outsize; unsigned char *bufptr = _outpos + _outsize;
const size_t n = const size_t n =