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

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