File p_xterm-CVE-2008-2383-fix.patch of Package xterm

--- xterm-236/charproc.c
+++ xterm-236/charproc.c
@@ -389,8 +389,10 @@
 static XtResource resources[] =
 {
     Bres(XtNallowSendEvents, XtCAllowSendEvents, screen.allowSendEvent0, False),
+    Bres(XtNallowFontOps, XtCAllowFontOps, screen.allowFontOp0, False),
+    Bres(XtNallowTcapOps, XtCAllowTcapOps, screen.allowTcapOp0, False),
     Bres(XtNallowTitleOps, XtCAllowTitleOps, screen.allowTitleOp0, True),
-    Bres(XtNallowWindowOps, XtCAllowWindowOps, screen.allowWindowOp0, True),
+    Bres(XtNallowWindowOps, XtCAllowWindowOps, screen.allowWindowOp0, False),
     Bres(XtNaltIsNotMeta, XtCAltIsNotMeta, screen.alt_is_not_meta, False),
     Bres(XtNaltSendsEscape, XtCAltSendsEscape, screen.alt_sends_esc, False),
     Bres(XtNalwaysBoldMode, XtCAlwaysBoldMode, screen.always_bold_mode, False),
@@ -5563,11 +5565,15 @@
     init_Bres(screen.meta_sends_esc);
 
     init_Bres(screen.allowSendEvent0);
+    init_Bres(screen.allowFontOp0);
+    init_Bres(screen.allowTcapOp0);
     init_Bres(screen.allowTitleOp0);
     init_Bres(screen.allowWindowOp0);
 
     /* make a copy so that editres cannot change the resource after startup */
     wnew->screen.allowSendEvents = wnew->screen.allowSendEvent0;
+    wnew->screen.allowFontOps = wnew->screen.allowFontOp0;
+    wnew->screen.allowTcapOps = wnew->screen.allowTcapOp0;
     wnew->screen.allowTitleOps = wnew->screen.allowTitleOp0;
     wnew->screen.allowWindowOps = wnew->screen.allowWindowOp0;
 
--- xterm-236/misc.c
+++ xterm-236/misc.c
@@ -2348,7 +2348,8 @@
 	break;
 
     case 3:			/* change X property */
-	ChangeXprop(buf);
+	if (screen->allowWindowOps)
+	    ChangeXprop(buf);
 	break;
 #if OPT_ISO_COLORS
     case 4:
@@ -2401,7 +2402,9 @@
 
     case 50:
 #if OPT_SHIFT_FONTS
-	if (buf != 0 && !strcmp(buf, "?")) {
+	if (!screen->allowFontOps && xw->misc.shift_fonts) {
+	    ;			/* disabled via resource or control-sequence */
+	} else if (buf != 0 && !strcmp(buf, "?")) {
 	    int num = screen->menu_font_number;
 
 	    unparseputc1(xw, ANSI_OSC);
@@ -2472,7 +2475,7 @@
 
 #if OPT_PASTE64
     case 52:
-	if (screen->allowWindowOps && (buf != 0))
+	if (screen->allowWindowOps)
 	    ManipulateSelectionData(xw, screen, buf, final);
 	break;
 #endif
@@ -2813,14 +2816,17 @@
 	    } else
 		okay = False;
 
-	    unparseputc1(xw, ANSI_DCS);
-	    unparseputc(xw, okay ? '1' : '0');
-	    unparseputc(xw, '$');
-	    unparseputc(xw, 'r');
-	    if (okay)
+	    if (okay) {
+		unparseputc1(xw, ANSI_DCS);
+		unparseputc(xw, okay ? '1' : '0');
+		unparseputc(xw, '$');
+		unparseputc(xw, 'r');
 		cp = reply;
-	    unparseputs(xw, cp);
-	    unparseputc1(xw, ANSI_ST);
+		unparseputs(xw, cp);
+		unparseputc1(xw, ANSI_ST);
+	    } else {
+		unparseputc(xw, ANSI_CAN);
+	    }
 	} else {
 	    unparseputc(xw, ANSI_CAN);
 	}
@@ -2828,7 +2834,7 @@
 #if OPT_TCAP_QUERY
     case '+':
 	cp++;
-	if (*cp == 'q') {
+	if ((*cp == 'q') && screen->allowTcapOps) {
 	    Bool fkey;
 	    unsigned state;
 	    int code;
@@ -2892,16 +2898,18 @@
 	break;
 #endif
     default:
-	parse_ansi_params(&params, &cp);
-	switch (params.a_final) {
-	case '|':		/* DECUDK */
-	    if (params.a_param[0] == 0)
-		reset_decudk();
-	    parse_decudk(cp);
-	    break;
-	case '{':		/* DECDLD (no '}' case though) */
-	    parse_decdld(&params, cp);
-	    break;
+	if (screen->terminal_id >= 200) {	/* VT220 */
+	    parse_ansi_params(&params, &cp);
+	    switch (params.a_final) {
+	    case '|':		/* DECUDK */
+		if (params.a_param[0] == 0)
+		    reset_decudk();
+		parse_decudk(cp);
+		break;
+	    case '{':		/* DECDLD (no '}' case though) */
+		parse_decdld(&params, cp);
+		break;
+	    }
 	}
 	break;
     }
--- xterm-237/ptyx.h	2008-09-14 17:16:20.000000000 +0200
+++ xterm-238/ptyx.h	2008-12-30 18:22:55.000000000 +0100
@@ -1405,12 +1412,19 @@
 	Boolean		bellOnReset;	/* bellOnReset			*/
 	Boolean		visualbell;	/* visual bell mode		*/
 	Boolean		poponbell;	/* pop on bell mode		*/
+
+	Boolean		allowFontOps;	/* FontOps mode			*/
 	Boolean		allowSendEvents;/* SendEvent mode		*/
+	Boolean		allowTcapOps;	/* TcapOps mode			*/
 	Boolean		allowTitleOps;	/* TitleOps mode		*/
 	Boolean		allowWindowOps;	/* WindowOps mode		*/
+
+	Boolean		allowFontOp0;	/* initial FontOps mode		*/
 	Boolean		allowSendEvent0;/* initial SendEvent mode	*/
+	Boolean		allowTcapOp0;	/* initial TcapOps mode		*/
 	Boolean		allowTitleOp0;	/* initial TitleOps mode	*/
 	Boolean		allowWindowOp0;	/* initial WindowOps mode	*/
+
 	Boolean		awaitInput;	/* select-timeout mode		*/
 	Boolean		grabbedKbd;	/* keyboard is grabbed		*/
 #ifdef ALLOWLOGGING
--- xterm-236/xterm.h
+++ xterm-236/xterm.h
@@ -331,7 +331,9 @@
 /***====================================================================***/
 
 #define XtNallowC1Printable	"allowC1Printable"
+#define XtNallowFontOps		"allowFontOps"
 #define XtNallowSendEvents	"allowSendEvents"
+#define XtNallowTcapOps		"allowTcapOps"
 #define XtNallowTitleOps	"allowTitleOps"
 #define XtNallowWindowOps	"allowWindowOps"
 #define XtNaltIsNotMeta		"altIsNotMeta"
@@ -485,7 +487,9 @@
 #define XtNxmcMoveSGR		"xmcMoveSGR"
 
 #define XtCAllowC1Printable	"AllowC1Printable"
+#define XtCAllowFontOps		"AllowFontOps"
 #define XtCAllowSendEvents	"AllowSendEvents"
+#define XtCAllowTcapOps		"AllowTcapOps"
 #define XtCAllowTitleOps	"AllowTitleOps"
 #define XtCAllowWindowOps	"AllowWindowOps"
 #define XtCAltIsNotMeta		"AltIsNotMeta"
--- xterm-236/xterm.man
+++ xterm-236/xterm.man
@@ -1440,6 +1440,10 @@
 Although this corresponds to no particular standard,
 some users insist it is a VT100.
 The default is ``false.''
+.TP
+.B "allowFontOps (\fPclass\fB AllowFontOps)"
+Specifies whether control sequences that set/query the font should be allowed.
+The default is ``false.''
 .TP 8
 .B "allowSendEvents (\fPclass\fB AllowSendEvents)"
 Specifies whether or not synthetic key and button events (generated using
@@ -1449,6 +1453,12 @@
 such events creates a very large security hole.
 The default is ``false.''
 .TP
+.B "allowTcapOps (\fPclass\fB AllowTcapOps)"
+Specifies whether control sequences that query the terminal's
+notion of its function-key strings, as termcap or terminfo capabilities
+should be allowed.
+The default is ``false.''
+.TP
 .B "allowTitleOps (\fPclass\fB AllowTitleOps)"
 Specifies whether control sequences that modify the window title or icon name
 should be allowed.
@@ -1457,7 +1467,7 @@
 .B "allowWindowOps (\fPclass\fB AllowWindowOps)"
 Specifies whether extended window control sequences (as used in dtterm)
 should be allowed.
-The default is ``true.''
+The default is ``false.''
 .TP 8
 .B "altIsNotMeta (\fPclass\fB AltIsNotMeta\fP)"
 If ``true'', treat the Alt-key as if it were the Meta-key.
openSUSE Build Service is sponsored by