blob: 4ac820fde2725ae21979b2d4bc0005369daa70d2 [file] [log] [blame]
Patrick Williamsf1e5d692016-03-30 15:21:19 -05001Bug: 45713
2
3How to reproduce:
4Run this command inside screen
5$ printf '\x1b[10000000T'
6
7screen will recursively call MScrollV to depth n/256.
8This is time consuming and will overflow stack if n is huge.
9
10Fixes CVE-2015-6806
11
12Upstream-Status: Backport
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050013CVE: CVE-2015-6806
Patrick Williamsf1e5d692016-03-30 15:21:19 -050014
15Signed-off-by: Kuang-che Wu <kcwu@csie.org>
16Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
17Signed-off-by: Maxin B. John <maxin.john@intel.com>
18---
19diff -Naur screen-4.3.1-orig/ansi.c screen-4.3.1/ansi.c
20--- screen-4.3.1-orig/ansi.c 2015-06-29 00:22:55.000000000 +0300
21+++ screen-4.3.1/ansi.c 2015-10-06 13:13:58.297648039 +0300
22@@ -2502,13 +2502,13 @@
23 return;
24 if (n > 0)
25 {
26+ if (ye - ys + 1 < n)
27+ n = ye - ys + 1;
28 if (n > 256)
29 {
30 MScrollV(p, n - 256, ys, ye, bce);
31 n = 256;
32 }
33- if (ye - ys + 1 < n)
34- n = ye - ys + 1;
35 #ifdef COPY_PASTE
36 if (compacthist)
37 {
38@@ -2562,15 +2562,15 @@
39 }
40 else
41 {
42- if (n < -256)
43- {
44- MScrollV(p, n + 256, ys, ye, bce);
45- n = -256;
46- }
47 n = -n;
48 if (ye - ys + 1 < n)
49 n = ye - ys + 1;
50
51+ if (n > 256)
52+ {
53+ MScrollV(p, - (n - 256), ys, ye, bce);
54+ n = 256;
55+ }
56 ml = p->w_mlines + ye;
57 /* Clear lines */
58 for (i = ye; i > ye - n; i--, ml--)