Blame SOURCES/0012-quic-Check-RLE-lengths.patch

84be6c
From d45a4954d73b41a255b8b4ec57c01ae87ec2936e Mon Sep 17 00:00:00 2001
84be6c
From: Frediano Ziglio <freddy77@gmail.com>
84be6c
Date: Wed, 29 Apr 2020 15:11:38 +0100
84be6c
Subject: [PATCH spice-common 3/4] quic: Check RLE lengths
84be6c
84be6c
Avoid buffer overflows decoding images. On compression we compute
84be6c
lengths till end of line so it won't cause regressions.
84be6c
Proved by fuzzing the code.
84be6c
84be6c
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
84be6c
Acked-by: Uri Lublin <uril@redhat.com>
84be6c
---
84be6c
 common/quic_tmpl.c | 6 +++++-
84be6c
 1 file changed, 5 insertions(+), 1 deletion(-)
84be6c
84be6c
diff --git a/subprojects/spice-common/common/quic_tmpl.c b/subprojects/spice-common/common/quic_tmpl.c
84be6c
index f0a4927..11e09f5 100644
84be6c
--- a/subprojects/spice-common/common/quic_tmpl.c
84be6c
+++ b/subprojects/spice-common/common/quic_tmpl.c
84be6c
@@ -570,7 +570,11 @@ static void FNAME_DECL(uncompress_row_seg)(const PIXEL * const prev_row,
84be6c
 do_run:
84be6c
         state->waitcnt = stopidx - i;
84be6c
         run_index = i;
84be6c
-        run_end = i + decode_state_run(encoder, state);
84be6c
+        run_end = decode_state_run(encoder, state);
84be6c
+        if (run_end < 0 || run_end > (end - i)) {
84be6c
+            encoder->usr->error(encoder->usr, "wrong RLE\n");
84be6c
+        }
84be6c
+        run_end += i;
84be6c
 
84be6c
         for (; i < run_end; i++) {
84be6c
             UNCOMPRESS_PIX_START(&cur_row[i]);
84be6c
-- 
84be6c
2.25.4
84be6c