From: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
To: svt-core@virtuozzo.com
Cc: andrey.drobyshev@virtuozzo.com, den@openvz.org
Subject: [QEMU HCI-8.0 PATCH 09/15] ui/vnc: use RFB wire types for client message handlers
Date: Fri, 4 Sep 2026 13:11:59 +0300 [thread overview]
Message-ID: <20260904101206.701978-10-andrey.drobyshev@virtuozzo.com> (raw)
In-Reply-To: <20260904101206.701978-1-andrey.drobyshev@virtuozzo.com>
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Use exact-width unsigned types for the static functions that process
RFB client messages, matching the types returned by read_u8(),
read_u16(), and read_u32():
- set_pixel_format: uint8_t/uint16_t for pixel format fields
- pointer_event: uint8_t button_mask, uint16_t x/y
- key_event/ext_key_event: bool down, uint32_t sym/keycode
- do_key_event: uint32_t sym
- framebuffer_update_request: uint8_t incremental, uint16_t x/y/w/h
Drop needless declarations.
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Marc-Andre Lureau <marcandre.lureau@redhat.com>
(cherry picked from commit 3162692a3b67603e2b01f0c6441daa682acd6164)
---
ui/vnc.c | 39 +++++++++++++++++----------------------
1 file changed, 17 insertions(+), 22 deletions(-)
diff --git a/ui/vnc.c b/ui/vnc.c
index a311f74e8b9..d76a777cc94 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -610,15 +610,7 @@ bool vnc_display_reload_certs(const char *id, Error **errp)
3) resolutions > 1024
*/
-static int vnc_update_client(VncState *vs, int has_dirty);
-static void vnc_disconnect_start(VncState *vs);
-
static void vnc_colordepth(VncState *vs);
-static void framebuffer_update_request(VncState *vs, int incremental,
- int x_position, int y_position,
- int w, int h);
-static void vnc_refresh(DisplayChangeListener *dcl);
-static int vnc_refresh_server_surface(VncDisplay *vd);
static int vnc_width(VncDisplay *vd)
{
@@ -1780,7 +1772,8 @@ static void check_pointer_type_change(Notifier *notifier, void *data)
vs->absolute = absolute;
}
-static void pointer_event(VncState *vs, int button_mask, int x, int y)
+static void pointer_event(VncState *vs, uint8_t button_mask,
+ uint16_t x, uint16_t y)
{
static uint32_t bmap[INPUT_BUTTON__MAX] = {
[INPUT_BUTTON_LEFT] = 0x01,
@@ -1857,7 +1850,7 @@ static void kbd_leds(void *opaque, int ledstate)
}
}
-static void do_key_event(VncState *vs, int down, int keycode, int sym)
+static void do_key_event(VncState *vs, int down, int keycode, uint32_t sym)
{
QKeyCode qcode = qemu_input_key_number_to_qcode(keycode);
@@ -2036,7 +2029,7 @@ static const char *code2name(int keycode)
return QKeyCode_str(qemu_input_key_number_to_qcode(keycode));
}
-static void key_event(VncState *vs, int down, uint32_t sym)
+static void key_event(VncState *vs, bool down, uint32_t sym)
{
int keycode;
int lsym = sym;
@@ -2051,8 +2044,8 @@ static void key_event(VncState *vs, int down, uint32_t sym)
do_key_event(vs, down, keycode, sym);
}
-static void ext_key_event(VncState *vs, int down,
- uint32_t sym, uint16_t keycode)
+static void ext_key_event(VncState *vs, bool down,
+ uint32_t sym, uint32_t keycode)
{
/* if the user specifies a keyboard layout, always use it */
if (keyboard_layout) {
@@ -2063,8 +2056,9 @@ static void ext_key_event(VncState *vs, int down,
}
}
-static void framebuffer_update_request(VncState *vs, int incremental,
- int x, int y, int w, int h)
+static void framebuffer_update_request(VncState *vs, uint8_t incremental,
+ uint16_t x, uint16_t y,
+ uint16_t w, uint16_t h)
{
if (incremental) {
if (vs->update != VNC_STATE_UPDATE_FORCE) {
@@ -2267,10 +2261,11 @@ static void send_color_map(VncState *vs)
vnc_unlock_output(vs);
}
-static void set_pixel_format(VncState *vs, int bits_per_pixel,
- int big_endian_flag, int true_color_flag,
- int red_max, int green_max, int blue_max,
- int red_shift, int green_shift, int blue_shift)
+static void set_pixel_format(VncState *vs, uint8_t bits_per_pixel,
+ uint8_t big_endian_flag, uint8_t true_color_flag,
+ uint16_t red_max, uint16_t green_max,
+ uint16_t blue_max, uint8_t red_shift,
+ uint8_t green_shift, uint8_t blue_shift)
{
if (!true_color_flag) {
/* Expose a reasonable default 256 color map */
@@ -2303,15 +2298,15 @@ static void set_pixel_format(VncState *vs, int bits_per_pixel,
vs->client_pf.rmax = red_max ? red_max : 0xFF;
vs->client_pf.rbits = ctpopl(red_max);
vs->client_pf.rshift = red_shift;
- vs->client_pf.rmask = red_max << red_shift;
+ vs->client_pf.rmask = (uint32_t)red_max << red_shift;
vs->client_pf.gmax = green_max ? green_max : 0xFF;
vs->client_pf.gbits = ctpopl(green_max);
vs->client_pf.gshift = green_shift;
- vs->client_pf.gmask = green_max << green_shift;
+ vs->client_pf.gmask = (uint32_t)green_max << green_shift;
vs->client_pf.bmax = blue_max ? blue_max : 0xFF;
vs->client_pf.bbits = ctpopl(blue_max);
vs->client_pf.bshift = blue_shift;
- vs->client_pf.bmask = blue_max << blue_shift;
+ vs->client_pf.bmask = (uint32_t)blue_max << blue_shift;
vs->client_pf.bits_per_pixel = bits_per_pixel;
vs->client_pf.bytes_per_pixel = bits_per_pixel / 8;
vs->client_pf.depth = bits_per_pixel == 32 ? 24 : bits_per_pixel;
--
2.47.1
next prev parent reply other threads:[~2026-09-04 10:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 10:11 [QEMU HCI-8.0 PATCH 00/15] VNC stability fixes Andrey Drobyshev
2026-09-04 10:11 ` [QEMU HCI-8.0 PATCH 01/15] ui/vnc-jobs: fix VncRectEntry leak on job cleanup Andrey Drobyshev
2026-09-04 10:11 ` [QEMU HCI-8.0 PATCH 02/15] ui/vnc: fix OOB read access in VNC SASL mechname array Andrey Drobyshev
2026-09-04 10:11 ` [QEMU HCI-8.0 PATCH 03/15] ui/vnc: fix OOB write in VNC stats array Andrey Drobyshev
2026-09-04 10:11 ` [QEMU HCI-8.0 PATCH 04/15] ui/vnc: fix OOB write in lossy rect worker code Andrey Drobyshev
2026-09-04 10:11 ` [QEMU HCI-8.0 PATCH 05/15] ui/vnc: fix OOB read updating VNC update frequency stats Andrey Drobyshev
2026-09-04 10:11 ` [QEMU HCI-8.0 PATCH 06/15] ui: fix validation of VNC extended clipboard data length Andrey Drobyshev
2026-09-04 10:11 ` [QEMU HCI-8.0 PATCH 07/15] ui/vnc: fix OOB write in vnc_refresh_lossy_rect Andrey Drobyshev
2026-09-04 10:11 ` [QEMU HCI-8.0 PATCH 08/15] ui/vnc: validate color shifts in SetPixelFormat Andrey Drobyshev
2026-09-04 10:11 ` Andrey Drobyshev [this message]
2026-09-04 10:12 ` [QEMU HCI-8.0 PATCH 10/15] ui/vnc: fix out-of-bounds write in lossy refresh dirty marking Andrey Drobyshev
2026-09-04 10:12 ` [QEMU HCI-8.0 PATCH 11/15] ui/vnc: validate SetPixelFormat field ranges Andrey Drobyshev
2026-09-04 10:12 ` [QEMU HCI-8.0 PATCH 12/15] ui/vnc: remove redundant rows computation Andrey Drobyshev
2026-09-04 10:12 ` [QEMU HCI-8.0 PATCH 13/15] ui/vnc: Fix crash when specifying [vnc] without id in the config file Andrey Drobyshev
2026-09-04 10:12 ` [QEMU HCI-8.0 PATCH 14/15] ui/vnc: Fix qemu abort when query vnc info Andrey Drobyshev
2026-09-04 10:12 ` [QEMU HCI-8.0 PATCH 15/15] ui/spice: fix crash when disabling GL scanout on Andrey Drobyshev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260904101206.701978-10-andrey.drobyshev@virtuozzo.com \
--to=andrey.drobyshev@virtuozzo.com \
--cc=den@openvz.org \
--cc=svt-core@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.