GUACAMOLE-2002: Warn on clipboard truncation instead of silently dropping data#679
Open
escra wants to merge 1 commit into
Open
GUACAMOLE-2002: Warn on clipboard truncation instead of silently dropping data#679escra wants to merge 1 commit into
escra wants to merge 1 commit into
Conversation
…ping data. Charset expansion (UTF-8 -> UTF-16, CRLF translation, or multi-byte characters such as emoji) can make converted clipboard data outgrow the configured clipboard buffer. guac_iconv() signals this by returning 0, but the RDP (cliprdr) and VNC clipboard paths ignored that return value. RDP and VNC now detect a zero return and log a GUAC_LOG_WARNING that names the byte limit and points the operator at the clipboard-buffer-size setting. For inbound RDP data the converted (possibly partial) text is still delivered and recorded rather than dropped entirely, since truncated clipboard text is still useful.
5 tasks
necouchman
reviewed
Jun 18, 2026
necouchman
left a comment
Contributor
There was a problem hiding this comment.
Overall I'm fine with the changes - I do have one question: Is this worth trying to warn the user about rather than the admin? The logs will only go to the admin, but I'm wondering if sending a message to the user, similar to what we do for things like admins joining a session or file uploads would be useful?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Building on the configurable clipboard buffer work in GUACAMOLE-2002, this addresses a remaining silent-failure case: charset expansion during clipboard conversion can make the converted data outgrow the configured
clipboard-buffer-size.clipboard->availableonly bounds the input; it does not account for expansion such as UTF-8 ↔ UTF-16, CRLF translation, or multi-byte characters (e.g. emoji).guac_iconv()signals this by returning0(output buffer filled before all input was consumed), but the RDP (cliprdr) and VNC clipboard paths ignored that return value, so oversized clipboard transfers were silently truncated or dropped with no operator-visible signal.Changes
cliprdr.c(both the clipboard request and theformat_data_responsedirections) and VNCclipboard.c(end_handlerandcut_textdirections) now check theguac_iconv()return value.GUAC_LOG_WARNINGnaming the byte limit and pointing the operator at theclipboard-buffer-sizesetting.main's heap-allocated clipboard buffers (guac_mem_alloc(clipboard->available)) and the clipboard recording added in GUACAMOLE-1969.Relation to #659 and reviewer feedback
This follows up on #659 (now closed). In that thread @bbennett-ks and @eugen-keeper raised that simply over-allocating the buffer (e.g.
available * 4to absorb worst-case expansion) is unsafe — with a 50 MiBclipboard-buffer-sizethat would mean pre-allocating up to 200 MiB per clipboard transfer.This PR deliberately chooses detection + warning over pre-allocation: the allocation stays bound to the operator-configured
clipboard-buffer-size, and overflow is reported cleanly (with partial delivery where possible) instead of either silently dropping data or ballooning memory. cc @bbennett-ks @eugen-keeperValidation
guac_iconvCUnit suite with a truncation case (test_iconv__truncation) asserting a0return and no overflow for ASCII→UTF-16, CRLF, and emoji expansion.test_guacamole_2002_clipboard.shandtest_cliprdr_hardening.sh(static + functional checks), wired into our pipeline.Relates to / follows up on #659.