This is a big one. Many servers (including LibVNCServer) can't properly handle zlib streams created by compress() function of zlib library. When decompressing such streams, inflate() correctly returns Z_STREAM_END, but these servers are only expecting Z_OK. So they end up crashing, while LibVNCserver abruptly disconnects from client.
This is probably why the original PR #552 was not working. New PR simply suppressed it by adding extra byte, which made inflate() return Z_OK.
According to spec, clipboard text is null terminated and text length includes the null byte. This is how LibVNCServer and other clients encode this. Fixed by 2nd commit https://github.com/LibVNC/libvncserver/commit/7ff0a53d565b6f03380b08b89d05757be82b9c34
This is a big one. Many servers (including LibVNCServer) can't properly handle zlib streams created by
compress()
function of zlib library. When decompressing such streams,inflate()
correctly returnsZ_STREAM_END
, but these servers are only expectingZ_OK
. So they end up crashing, while LibVNCserver abruptly disconnects from client.This is probably why the original PR #552 was not working. New PR simply suppressed it by adding extra byte, which made
inflate()
returnZ_OK
.Solution: