[Spice-devel] [PATCH spice] inputs_channel: Fix wrong handling of key up/down on big endian
Alon Levy
alevy at redhat.com
Thu Oct 18 08:49:07 PDT 2012
ACK.
> The client will send 0x000000## codes for regular keys, and
> 0x0000##e0 codes
> for extended keys. The current code which simply walks the uint32_t
> code in
> memory order relies on the memory order being little endian, which
> will
> clearly fail on big endian machines, this fixes this.
>
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
> server/inputs_channel.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/server/inputs_channel.c b/server/inputs_channel.c
> index bf5c22e..1a64e2d 100644
> --- a/server/inputs_channel.c
> +++ b/server/inputs_channel.c
> @@ -309,6 +309,7 @@ static int
> inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size,
> ui
> InputsChannel *inputs_channel = (InputsChannel *)rcc->channel;
> InputsChannelClient *icc = (InputsChannelClient *)rcc;
> uint8_t *buf = (uint8_t *)message;
> + uint32_t i;
>
> spice_assert(g_inputs_channel == inputs_channel);
> switch (type) {
> @@ -321,15 +322,16 @@ static int
> inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size,
> ui
> }
> case SPICE_MSGC_INPUTS_KEY_UP: {
> SpiceMsgcKeyDown *key_down = (SpiceMsgcKeyDown *)buf;
> - uint8_t *now = (uint8_t *)&key_down->code;
> - uint8_t *end = now + sizeof(key_down->code);
> - for (; now < end && *now; now++) {
> - kbd_push_scan(keyboard, *now);
> + for (i = 0; i < 4; i++) {
> + uint8_t code = (key_down->code >> (i * 8)) & 0xff;
> + if (code == 0) {
> + break;
> + }
> + kbd_push_scan(keyboard, code);
> }
> break;
> }
> case SPICE_MSGC_INPUTS_KEY_SCANCODE: {
> - uint32_t i;
> uint8_t *code = (uint8_t *)buf;
> for (i = 0; i < size; i++) {
> kbd_push_scan(keyboard, code[i]);
> --
> 1.7.12.1
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>
More information about the Spice-devel
mailing list