zeromq / libzmq

ZeroMQ core engine in C++, implements ZMTP/3.1
https://www.zeromq.org
Mozilla Public License 2.0
9.71k stars 2.35k forks source link

BUG when setting a low ZMQ_MAXMSGSIZE option #4436

Open ThibaultDECO opened 2 years ago

ThibaultDECO commented 2 years ago

I encounter a problem when setting a low value for the ZMQ_MAXMSGSIZE option. With TCP, CURVE and a PUB/SUB, on my environment, whenever the value is between 0 and 275, the connection fails and no messages are received. It starts working with the value 276 (which I guess corresponds to the size of the INITIATE command for CURVE).

I assume this is due to the handshake failing? Indeed, in zmtp_engine.cpp, the handshake takes the ZMQ_MAXMSGSIZE option as an argument in vX_decoder_t (_options.in_batch_size, _options.maxmsgsize).

I would either recommend to either make the handshake function ignore the ZMQ_MAXMSGSIZE option by taking an argument -1 instead of _options.maxmsgsize, or set a lower bound for the authorised input of the ZMQ_MAXMSGSIZE option. One could also specify in the manual that the ZMQ_MAXMSGSIZE option also applies to the handshake and that an appropriate lower bound should be used.