Blame SOURCES/libvncserver-0.9.11-CVE-2019-20840.patch

217285
Backport of:
217285
From 0cf1400c61850065de590d403f6d49e32882fd76 Mon Sep 17 00:00:00 2001
217285
From: Rolf Eike Beer <eike@sf-mail.de>
217285
Date: Tue, 28 May 2019 18:30:46 +0200
217285
Subject: [PATCH] fix crash because of unaligned accesses in
217285
 hybiReadAndDecode()
217285
217285
[Ubuntu note: patch backported to apply on libvncserver/websockets.c instead of
217285
libvncserver/ws_decode.c
217285
 -- Avital]
217285
217285
---
217285
 libvncserver/ws_decode.c | 7 ++++---
217285
 1 file changed, 4 insertions(+), 3 deletions(-)
217285
217285
--- a/libvncserver/websockets.c
217285
+++ b/libvncserver/websockets.c
217285
@@ -880,7 +880,6 @@ hybiReadAndDecode(rfbClientPtr cl, char
217285
   int bufsize;
217285
   int nextRead;
217285
   unsigned char *data;
217285
-  uint32_t *data32;
217285
   ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx;
217285
 
217285
   /* if data was carried over, copy to start of buffer */
217285
@@ -938,10 +937,12 @@ hybiReadAndDecode(rfbClientPtr cl, char
217285
   /* for a possible base64 decoding, we decode multiples of 4 bytes until
217285
    * the whole frame is received and carry over any remaining bytes in the carry buf*/
217285
   data = (unsigned char *)hybiPayloadStart(wsctx);
217285
-  data32= (uint32_t *)data;
217285
 
217285
   for (i = 0; i < (toDecode >> 2); i++) {
217285
-    data32[i] ^= wsctx->header.mask.u;
217285
+    uint32_t tmp;
217285
+    memcpy(&tmp, data + i * sizeof(tmp), sizeof(tmp));
217285
+    tmp ^= wsctx->header.mask.u;
217285
+    memcpy(data + i * sizeof(tmp), &tmp, sizeof(tmp));
217285
   }
217285
   rfbLog("mask decoding; i=%d toDecode=%d\n", i, toDecode);
217285