ui/vnc-clipboard: fix inflate_buffer
authorFiona Ebner <f.ebner@proxmox.com>
Wed, 22 Nov 2023 12:58:26 +0000 (13:58 +0100)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 4 Dec 2023 07:28:26 +0000 (11:28 +0400)
Commit d921fea338 ("ui/vnc-clipboard: fix infinite loop in
inflate_buffer (CVE-2023-3255)") removed this hunk, but it is still
required, because it can happen that stream.avail_in becomes zero
before coming across a return value of Z_STREAM_END in the loop.

This fixes the host->guest direction of the clipboard with noVNC and
TigerVNC as clients.

Fixes: d921fea338 ("ui/vnc-clipboard: fix infinite loop in inflate_buffer (CVE-2023-3255)")
Reported-by: Friedrich Weber <f.weber@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20231122125826.228189-1-f.ebner@proxmox.com>

ui/vnc-clipboard.c

index c759be343814552ae4bbac583f0f9688e19721d5..124b6fbd9c23c8b38204dd9a4b4e00ab6e7ef6c6 100644 (file)
@@ -69,6 +69,11 @@ static uint8_t *inflate_buffer(uint8_t *in, uint32_t in_len, uint32_t *size)
         }
     }
 
+    *size = stream.total_out;
+    inflateEnd(&stream);
+
+    return out;
+
 err_end:
     inflateEnd(&stream);
 err: