system/vncviewer: Drain truncated desktop names#3595
Conversation
The RFB ServerInit message carries the desktop name as a length-prefixed field. vncviewer caps the copied name to fit conn->name, but it must still consume the remaining bytes from the socket when the advertised name is longer than the local buffer. Drain the unused suffix so the next RFB message is read from the correct boundary. Reuse the same discard helper for other skipped RFB payloads. Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
|
@JianyuWang0623 could you please take a look? :-) |
|
@Old-Ding Thanks for the fix — the analysis of the desktop-name desync looks correct to me. One concern about the Testing section: the listed checks ( Specifically it would help to have:
Also, since this touches parsing of an attacker-controllable length field, it would be good to confirm the behavior when the server advertises a very large Finally, please run |
Summary
conn->nameWhy
The RFB ServerInit desktop name is a length-prefixed field. When the server advertises a name longer than the local buffer, vncviewer truncated the copy length before reading from the socket. That left the remaining name bytes queued as if they were the next RFB message, which can desynchronize subsequent framebuffer update parsing.
Testing
git diff --check origin/master..HEADgit show --check --stat --oneline HEADcheckpatch.sh; not run because this Windows environment has no usable WSL/bash shell