Blame SOURCES/screen-4.1.0-CVE-2021-26937.patch

cbf1f4
diff -urNp a/src/ansi.c b/src/ansi.c
cbf1f4
--- a/src/ansi.c	2021-02-18 08:54:07.204178181 +0100
cbf1f4
+++ b/src/ansi.c	2021-02-18 08:56:24.814479439 +0100
cbf1f4
@@ -691,10 +691,6 @@ register int len;
cbf1f4
 		    }
cbf1f4
 		  curr->w_rend.font = 0;
cbf1f4
 		}
cbf1f4
-#  ifdef DW_CHARS
cbf1f4
-	      if (curr->w_encoding == UTF8 && utf8_isdouble(c))
cbf1f4
-		curr->w_mbcs = 0xff;
cbf1f4
-#  endif
cbf1f4
 	      if (curr->w_encoding == UTF8 && c >= 0x0300 && utf8_iscomb(c))
cbf1f4
 		{
cbf1f4
 		  int ox, oy;
cbf1f4
@@ -729,6 +725,11 @@ register int len;
cbf1f4
 		    }
cbf1f4
 		  break;
cbf1f4
 		}
cbf1f4
+#  ifdef DW_CHARS
cbf1f4
+       if (curr->w_encoding == UTF8 && utf8_isdouble(c))
cbf1f4
+         curr->w_mbcs = 0xff;
cbf1f4
+#  endif
cbf1f4
+
cbf1f4
 	      font = curr->w_rend.font;
cbf1f4
 # endif
cbf1f4
 # ifdef DW_CHARS
cbf1f4
diff -urNp a/src/encoding.c b/src/encoding.c
cbf1f4
--- a/src/encoding.c	2021-02-18 08:54:07.193178077 +0100
cbf1f4
+++ b/src/encoding.c	2021-02-18 08:58:01.007386136 +0100
cbf1f4
@@ -43,7 +43,7 @@ static int  encmatch __P((char *, char *
cbf1f4
 # ifdef UTF8
cbf1f4
 static int   recode_char __P((int, int, int));
cbf1f4
 static int   recode_char_to_encoding __P((int, int));
cbf1f4
-static void  comb_tofront __P((int, int));
cbf1f4
+static void  comb_tofront __P((int));
cbf1f4
 #  ifdef DW_CHARS
cbf1f4
 static int   recode_char_dw __P((int, int *, int, int));
cbf1f4
 static int   recode_char_dw_to_encoding __P((int, int *, int));
cbf1f4
@@ -1012,11 +1012,12 @@ int c;
cbf1f4
 }
cbf1f4
 
cbf1f4
 static void
cbf1f4
-comb_tofront(root, i)
cbf1f4
-int root, i;
cbf1f4
+comb_tofront(i)
cbf1f4
+int i;
cbf1f4
 {
cbf1f4
   for (;;)
cbf1f4
     {
cbf1f4
+      int root = i >= 0x700 ? 0x801 : 0x800;
cbf1f4
       debug1("bring to front: %x\n", i);
cbf1f4
       combchars[combchars[i]->prev]->next = combchars[i]->next;
cbf1f4
       combchars[combchars[i]->next]->prev = combchars[i]->prev;
cbf1f4
@@ -1078,9 +1079,9 @@ struct mchar *mc;
cbf1f4
     {
cbf1f4
       /* full, recycle old entry */
cbf1f4
       if (c1 >= 0xd800 && c1 < 0xe000)
cbf1f4
-        comb_tofront(root, c1 - 0xd800);
cbf1f4
+        comb_tofront(c1 - 0xd800);
cbf1f4
       i = combchars[root]->prev;
cbf1f4
-      if (c1 == i + 0xd800)
cbf1f4
+      if (i == 0x800 || i == 0x801 || c1 == i + 0xd800)
cbf1f4
 	{
cbf1f4
 	  /* completely full, can't recycle */
cbf1f4
 	  debug("utf8_handle_comp: completely full!\n");
cbf1f4
@@ -1103,7 +1104,7 @@ struct mchar *mc;
cbf1f4
   mc->image = i & 0xff;
cbf1f4
   mc->font  = (i >> 8) + 0xd8;
cbf1f4
   debug3("combinig char %x %x -> %x\n", c1, c, i + 0xd800);
cbf1f4
-  comb_tofront(root, i);
cbf1f4
+  comb_tofront(i);
cbf1f4
 }
cbf1f4
 
cbf1f4
 #else /* !UTF8 */