[PATCH] quic: Check RLE lengths
authorFrediano Ziglio <freddy77@gmail.com>
Wed, 29 Apr 2020 14:11:38 +0000 (15:11 +0100)
committerUtkarsh Gupta <utkarsh@debian.org>
Sun, 1 Nov 2020 16:10:46 +0000 (16:10 +0000)
Avoid buffer overflows decoding images. On compression we compute
lengths till end of line so it won't cause regressions.
Proved by fuzzing the code.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <uril@redhat.com>
Gbp-Pq: Name CVE-2020-14355_part3.patch

spice-common/common/quic_tmpl.c

index e8393462c6f2cb3bfeae03f0b8b82553e3c11dd6..9035e81569dac9299d905c4c587e32b48388eed9 100644 (file)
@@ -563,11 +563,16 @@ do_run:
         channel->state.waitcnt = stopidx - i;
         run_index = i;
 #ifdef RLE_STAT
-        run_end = i + decode_channel_run(encoder, channel);
+        run_end = decode_channel_run(encoder, channel);
 #else
-        run_end = i + decode_run(encoder);
+        run_end = decode_run(encoder);
 #endif
 
+        if (run_end < 0 || run_end > (end - i)) {
+            encoder->usr->error(encoder->usr, "wrong RLE\n");
+        }
+        run_end += i;
+
         for (; i < run_end; i++) {
             cur_row[i].a = cur_row[i - 1].a;
         }