Make zlib encoding messages idempotent.

Otherwise duplicate messages can trigger a reinitialization of the
compression stream while the update thread is running.  Also ensure
that the stream is initialized before the update thread may attempt
to use it.

PR:		238333
Reviewed by:	cem, rgrimes
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D20673
This commit is contained in:
Mark Johnston 2019-06-19 16:09:20 +00:00
parent 49ee0fcea5
commit ab877e64d0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=349196

View File

@ -273,8 +273,10 @@ rfb_recv_set_encodings_msg(struct rfb_softc *rc, int cfd)
rc->enc_raw_ok = true;
break;
case RFB_ENCODING_ZLIB:
rc->enc_zlib_ok = true;
deflateInit(&rc->zstream, Z_BEST_SPEED);
if (!rc->enc_zlib_ok) {
deflateInit(&rc->zstream, Z_BEST_SPEED);
rc->enc_zlib_ok = true;
}
break;
case RFB_ENCODING_RESIZE:
rc->enc_resize_ok = true;