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

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