Skip to content

libvncserver: release sendMutex in rfbSendServerCutTextUTF8() without fallback - #769

Open
Roxas0Dev wants to merge 1 commit into
LibVNC:masterfrom
Roxas0Dev:cuttext-utf8-unlock
Open

Roxas0Dev wants to merge 1 commit into
LibVNC:masterfrom
Roxas0Dev:cuttext-utf8-unlock

Conversation

@Roxas0Dev

Copy link
Copy Markdown

rfbSendServerCutTextUTF8() takes the sendMutex of every client at the start of its loop. The Extended Clipboard branch and the Latin-1 fallback branch release it, but nothing does when the client has no Extended Clipboard and fallbackLatin1Str is NULL. The mutex then stays locked, and anything else sent to that client blocks: framebuffer updates, xvp replies, bells.

This dates back to the UTF-8 clipboard support (26bf374, LibVNCServer 0.9.14). Applications that always pass a Latin-1 fallback are not affected.

Found by @mikaelpelle while validating #768 (see #767).

Changes

  • Release the mutex in the missing else branch.
  • Add test/cuttexttest.c (CTest cuttext). A client connected through socketpair(), with no listening socket, receives a text with and without the fallback, and the test checks with pthread_mutex_trylock() that its sendMutex is free afterwards. The test is built everywhere and skips itself without pthreads, zlib or socketpair().

Testing

Linux x86_64, gcc 13, Debug and Release:

Not changed here

… fallback

rfbSendServerCutTextUTF8() locks the sendMutex of each client, but did
not unlock it for a client without Extended Clipboard when no Latin-1
fallback text is given. Nothing could be sent to that client afterwards.

Add cuttexttest, which checks that the mutex is released with and
without the fallback text.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants