File kterm-6.2.0-secure.diff of Package kterm

--- kterm-6.2.0.orig/charproc.c
+++ kterm-6.2.0/charproc.c
@@ -3642,7 +3642,6 @@
 	       *s,
 	       *ns,
 	       *end,
-		tmp[1024],
 	  	buf[32];
     XIM		xim = (XIM) NULL;
     XIMStyles  *xim_styles;
@@ -3669,17 +3668,18 @@
 	if ((p = XSetLocaleModifiers("@im=none")) != NULL && *p)
 	    xim = XOpenIM(XtDisplay(term), NULL, NULL, NULL);
     } else {
-	strcpy(tmp, term->misc.input_method);
-	for(ns=s=tmp; ns && *s;) {
+	for(ns=s=term->misc.input_method; ns && *s;) {
 	    while (*s && isspace(*s)) s++;
 	    if (!*s) break;
 	    if ((ns = end = index(s, ',')) == 0)
 		end = s + strlen(s);
 	    while (isspace(*end)) end--;
-	    *end = '\0';
 
 	    strcpy(buf, "@im=");
-	    strcat(buf, s);
+	    if (end - (s + (sizeof(buf) - 5)) > 0)
+		end = s + (sizeof(buf) - 5);
+	    strncat(buf, s, end - s);
+
 	    if ((p = XSetLocaleModifiers(buf)) != NULL && *p
 		&& (xim = XOpenIM(XtDisplay(term), NULL, NULL, NULL)) != NULL)
 		break;
@@ -3708,8 +3708,7 @@
     }
 
     found = False;
-    strcpy(tmp, term->misc.preedit_type);
-    for(s = tmp; s && !found;) {
+    for(s = term->misc.preedit_type; s && !found;) {
 	while (*s && isspace(*s)) s++;
 	if (!*s) break;
 	if (ns = end = index(s, ','))
@@ -3717,13 +3716,12 @@
 	else
 	    end = s + strlen(s);
 	while (isspace(*end)) end--;
-	*end = '\0';
 
-	if (!strcmp(s, "OverTheSpot")) {
+	if (!strncmp(s, "OverTheSpot", end - s)) {
 	    input_style = (XIMPreeditPosition | XIMStatusArea);
-	} else if (!strcmp(s, "OffTheSpot")) {
+	} else if (!strncmp(s, "OffTheSpot", end - s)) {
 	    input_style = (XIMPreeditArea | XIMStatusArea);
-	} else if (!strcmp(s, "Root")) {
+	} else if (!strncmp(s, "Root", end - s)) {
 	    input_style = (XIMPreeditNothing | XIMStatusNothing);
 	}
 	for (i = 0; (unsigned short)i < xim_styles->count_styles; i++)
@@ -4407,7 +4405,7 @@
 	XtOverrideTranslations(w, original);
 	return;
     }
-    (void) sprintf( mapName, "%sKeymap", params[0] );
+    (void) sprintf( mapName, "%*sKeymap", (int)sizeof(mapName) - 10, params[0] );
     (void) strcpy( mapClass, mapName );
     if (islower(mapClass[0])) mapClass[0] = toupper(mapClass[0]);
     XtGetSubresources( w, (XtPointer)&keymap, mapName, mapClass,
--- kterm-6.2.0.orig/main.c
+++ kterm-6.2.0/main.c
@@ -1152,7 +1152,9 @@
 
 #ifdef USE_TERMIOS /* { */
 	d_tio.c_cc[VSUSP] = CSUSP;
+#ifdef VDSUSP
 	d_tio.c_cc[VDSUSP] = CDSUSP;
+#endif /* VDSUSP */
 	d_tio.c_cc[VREPRINT] = CRPRNT;
 	d_tio.c_cc[VDISCARD] = CFLUSH;
 	d_tio.c_cc[VWERASE] = CWERASE;
@@ -1293,7 +1295,9 @@
 #endif	/* } TIOCSLTC */
 #ifdef USE_TERMIOS /* { */
 	d_tio.c_cc[VSUSP] = CSUSP;
+#ifdef VDSUP
 	d_tio.c_cc[VDSUSP] = '\000';
+#endif /* VDSUP */
 	d_tio.c_cc[VREPRINT] = '\377';
 	d_tio.c_cc[VDISCARD] = '\377';
 	d_tio.c_cc[VWERASE] = '\377';
@@ -2253,14 +2257,17 @@
 #ifndef KTERM_NOTEK
 	}
 #endif /* !KTERM_NOTEK */
+
+	*ptr = 0;
 	TermName = NULL;
 	if (resource.term_name) {
 	    if (tgetent (ptr, resource.term_name) == 1) {
 		TermName = resource.term_name;
+		if (*ptr) 
 #ifndef KTERM_NOTEK
-		if (!screen->TekEmu)
+		    if (!screen->TekEmu)
 #endif /* !KTERM_NOTEK */
-		    resize (screen, TermName, termcap, newtc);
+		        resize (screen, TermName, termcap, newtc);
 	    } else {
 		fprintf (stderr, "%s:  invalid termcap entry \"%s\".\n",
 			 ProgramName, resource.term_name);
@@ -2270,10 +2277,11 @@
 	    while (*envnew != NULL) {
 		if(tgetent(ptr, *envnew) == 1) {
 			TermName = *envnew;
+			if (*ptr) 
 #ifndef KTERM_NOTEK
-			if(!screen->TekEmu)
+			    if(!screen->TekEmu)
 #endif /* !KTERM_NOTEK */
-			    resize(screen, TermName, termcap, newtc);
+			        resize(screen, TermName, termcap, newtc);
 			break;
 		}
 		envnew++;
@@ -3149,8 +3157,10 @@
 # ifndef KTERM_NOTEK
 		if(!screen->TekEmu) {
 # endif /* !KTERM_NOTEK */
-		    strcpy (termcap, newtc);
-		    resize (screen, TermName, termcap, newtc);
+		    if(*newtc) {
+		        strcpy (termcap, newtc);
+		        resize (screen, TermName, termcap, newtc);
+		    }
 # ifndef KTERM_NOTEK
 		}
 # endif /* !KTERM_NOTEK */
@@ -3166,9 +3176,11 @@
 		    remove_termcap_entry (newtc, ":im=");
 		    remove_termcap_entry (newtc, ":ei=");
 		    remove_termcap_entry (newtc, ":mi");
-		    strcat (newtc, ":im=\\E[4h:ei=\\E[4l:mi:");
+		    if (*newtc)
+		        strcat (newtc, ":im=\\E[4h:ei=\\E[4l:mi:");
 		}
-		Setenv ("TERMCAP=", newtc);
+                if (*newtc)
+		    Setenv ("TERMCAP=", newtc);
 # ifdef sony
 		switch (jmode & KM_KANJI) {
 		case KM_JIS:
openSUSE Build Service is sponsored by