Release 6.3 Public Patch #03 Open Group X Project Team To apply this patch: cd to the top of the source tree (to the directory containing the "xc" subdirectory) and do: patch -p -s < ThisFile Patch will work silently unless an error occurs. If you want to watch patch do its thing, leave out the "-s" argument to patch. Finally, to rebuild after applying this patch, cd to the "xc" subdirectory and do: make Everything >& every.log This patch fixes buffer overflows in Xlib, Xt, Xaw, and xterm. Prereq: R6.3, public-patch-2 *** bug-report@@/main/R6.3-PATCH-2 Tue Dec 16 09:50:58 1997 --- xc/bug-report Wed May 13 09:10:24 1998 *************** *** 9,15 **** VERSION: ! R6.3, public-patch-2 [X Consortium public patches edit this line to indicate the patch level] CLIENT MACHINE and OPERATING SYSTEM: --- 9,15 ---- VERSION: ! R6.3, public-patch-3 [X Consortium public patches edit this line to indicate the patch level] CLIENT MACHINE and OPERATING SYSTEM: *** lib/X11/GetDflt.c@@/main/R6.3-PATCH-2 Wed Jun 11 06:44:56 1997 --- xc/lib/X11/GetDflt.c Tue May 12 11:13:50 1998 *************** *** 1,4 **** ! /* $TOG: GetDflt.c /main/56 1997/06/11 06:40:28 kaleb $ */ /*********************************************************** --- 1,4 ---- ! /* $TOG: GetDflt.c /main/56.0 1998/05/12 11:19:09 kaleb $ */ /*********************************************************** *************** *** 122,130 **** pw = _XGetpwnam(ptr,pwparams); else pw = _XGetpwuid(getuid(),pwparams); ! if (pw != NULL) ! (void) strcpy(dest, pw->pw_dir); ! else *dest = '\0'; } #endif --- 122,131 ---- pw = _XGetpwnam(ptr,pwparams); else pw = _XGetpwuid(getuid(),pwparams); ! if (pw != NULL) { ! (void) strncpy(dest, pw->pw_dir, len); ! dest[len-1] = '\0'; ! } else *dest = '\0'; } #endif *** lib/Xt/Initialize.c@@/main/R6.3-PATCH-2 Thu May 15 17:26:35 1997 --- xc/lib/Xt/Initialize.c Tue May 12 11:14:03 1998 *************** *** 1,4 **** ! /* $TOG: Initialize.c /main/210 1997/05/15 17:29:50 kaleb $ */ /*********************************************************** Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts --- 1,4 ---- ! /* $TOG: Initialize.c /main/210.0 1998/05/12 11:19:17 kaleb $ */ /*********************************************************** Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts *************** *** 243,251 **** (void) strncpy (dest, ptr, len); dest[len-1] = '\0'; } else { ! if ((pw = _XGetpwuid(getuid(),pwparams)) != NULL) ! (void) strcpy (dest, pw->pw_name); ! else *dest = '\0'; } #endif --- 238,247 ---- (void) strncpy (dest, ptr, len); dest[len-1] = '\0'; } else { ! if ((pw = _XGetpwuid(getuid(),pwparams)) != NULL) { ! (void) strncpy (dest, pw->pw_name, len); ! dest[len-1] = '\0'; ! } else *dest = '\0'; } #endif *************** *** 282,290 **** pw = _XGetpwnam(ptr,pwparams); else pw = _XGetpwuid(getuid(),pwparams); ! if (pw != NULL) ! (void) strcpy (dest, pw->pw_dir); ! else *dest = '\0'; } #endif --- 284,293 ---- pw = _XGetpwnam(ptr,pwparams); else pw = _XGetpwuid(getuid(),pwparams); ! if (pw != NULL) { ! (void) strncpy (dest, pw->pw_dir, len); ! dest[len-1] = '\0'; ! } else *dest = '\0'; } #endif *** lib/Xt/TMaction.c@@/main/R6.3-PATCH-2 Thu May 15 17:27:59 1997 --- xc/lib/Xt/TMaction.c Tue May 12 11:14:09 1998 *************** *** 1,4 **** ! /* $TOG: TMaction.c /main/28 1997/05/15 17:31:14 kaleb $ */ /*LINTLIBRARY*/ /*********************************************************** --- 1,4 ---- ! /* $TOG: TMaction.c /main/28.0 1998/05/12 11:19:24 kaleb $ */ /*LINTLIBRARY*/ /*********************************************************** *************** *** 148,187 **** TMBindData bindData; { TMSimpleStateTree stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[0]; ! Cardinal num_unbound; ! char message[10000]; ! register Cardinal num_chars; register Cardinal i, j; XtActionProc *procs; ! num_unbound = 0; ! (void) strcpy(message, "Actions not found: "); ! num_chars = strlen(message); ! for (i=0; ! i < xlations->numStateTrees; ! i++) { if (bindData->simple.isComplex) procs = TMGetComplexBindEntry(bindData, i)->procs; else procs = TMGetSimpleBindEntry(bindData, i)->procs; stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[i]; for (j=0; j < stateTree->numQuarks; j++) { if (procs[j] == NULL) { String s = XrmQuarkToString(stateTree->quarkTbl[j]); ! if (num_unbound != 0) { ! (void) strcpy(&message[num_chars], ", "); ! num_chars = num_chars + 2; ! } ! (void) strcpy(&message[num_chars], s); num_chars += strlen(s); num_unbound++; } } } ! message[num_chars] = '\0'; ! if (num_unbound != 0) ! XtWarningMsg(XtNtranslationError,"unboundActions",XtCXtToolkitError, ! message, (String *)NULL, (Cardinal *)NULL); } --- 143,206 ---- TMBindData bindData; { TMSimpleStateTree stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[0]; ! Cardinal num_unbound = 0; ! Cardinal num_params = 1; ! char* message; ! char messagebuf[1000]; ! String params[1]; ! register Cardinal num_chars = 0; register Cardinal i, j; XtActionProc *procs; ! char* msg_prefix = "Actions not found: "; ! for (i=0; i < xlations->numStateTrees; i++) { if (bindData->simple.isComplex) procs = TMGetComplexBindEntry(bindData, i)->procs; else procs = TMGetSimpleBindEntry(bindData, i)->procs; + stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[i]; for (j=0; j < stateTree->numQuarks; j++) { if (procs[j] == NULL) { String s = XrmQuarkToString(stateTree->quarkTbl[j]); ! if (num_unbound != 0) ! num_chars += 2; num_chars += strlen(s); num_unbound++; } } } ! if (num_unbound == 0) ! return; ! message = XtStackAlloc (num_chars + 1, messagebuf); ! if (message != NULL) { ! *message = '\0'; ! num_unbound = 0; ! stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[0]; ! for (i=0; i < xlations->numStateTrees; i++) { ! if (bindData->simple.isComplex) ! procs = TMGetComplexBindEntry(bindData, i)->procs; ! else ! procs = TMGetSimpleBindEntry(bindData, i)->procs; ! ! stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[i]; ! for (j=0; j < stateTree->numQuarks; j++) { ! if (procs[j] == NULL) { ! String s = XrmQuarkToString(stateTree->quarkTbl[j]); ! if (num_unbound != 0) ! (void) strcat(message, ", "); ! (void) strcat(message, s); ! num_unbound++; ! } ! } ! } ! message[num_chars] = '\0'; ! params[0] = message; ! XtWarningMsg(XtNtranslationError,"unboundActions",XtCXtToolkitError, ! "Actions not found: %s", ! params, &num_params); ! XtStackFree (message, messagebuf); ! } } *** lib/Xt/TMparse.c@@/main/R6.3-PATCH-2 Thu May 15 17:28:14 1997 --- xc/lib/Xt/TMparse.c Tue May 12 11:14:15 1998 *************** *** 1,4 **** ! /* $TOG: TMparse.c /main/119 1997/05/15 17:31:29 kaleb $ */ /*********************************************************** Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts, --- 1,4 ---- ! /* $TOG: TMparse.c /main/119.0 1998/05/12 11:19:31 kaleb $ */ /*********************************************************** Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts, *************** *** 466,487 **** } ! static void Syntax(str,str1) ! String str,str1; { Cardinal numChars; ! Cardinal num_params = 1; ! String params[1]; ! char message[1000]; ! (void)strcpy(message,str); ! numChars = strlen(message); ! (void) strcpy(&message[numChars], str1); ! numChars += strlen(str1); ! message[numChars] = '\0'; ! params[0] = message; XtWarningMsg(XtNtranslationParseError,"parseError",XtCXtToolkitError, ! "translation table syntax error: %s",params,&num_params); } --- 461,477 ---- } ! static void Syntax(str0,str1) ! String str0,str1; { Cardinal numChars; ! Cardinal num_params = 2; ! String params[2]; ! params[0] = str0; ! params[1] = str1; XtWarningMsg(XtNtranslationParseError,"parseError",XtCXtToolkitError, ! "translation table syntax error: %s %s",params,&num_params); } *************** *** 555,563 **** if (keysymR){ temp[count].knot = notR; temp[count].pair = FALSE; temp[count++].keysym = keysymR; } ! temp[count].knot = FALSE; temp[count].keysym = 0; } } --- 545,555 ---- if (keysymR){ temp[count].knot = notR; temp[count].pair = FALSE; + temp[count].ref_count = 0; temp[count++].keysym = keysymR; } ! temp[count].knot = temp[count].pair = FALSE; ! temp[count].ref_count = 0; temp[count].keysym = 0; } } *************** *** 654,663 **** } str = ScanIdent(str); if (start != str) { ! char modStr[100]; (void) memmove(modStr, start, str-start); modStr[str-start] = '\0'; *token_return = XrmStringToQuark(modStr); return str; } return str; --- 646,660 ---- } str = ScanIdent(str); if (start != str) { ! char modStrbuf[100]; ! char* modStr; ! ! modStr = XtStackAlloc (str - start + 1, modStrbuf); ! if (modStr == NULL) _XtAllocError (NULL); (void) memmove(modStr, start, str-start); modStr[str-start] = '\0'; *token_return = XrmStringToQuark(modStr); + XtStackFree (modStr, modStrbuf); return str; } return str; *************** *** 752,763 **** Boolean* error; { String start = str; ! char eventTypeStr[100]; ScanAlphanumeric(str); (void) memmove(eventTypeStr, start, str-start); eventTypeStr[str-start] = '\0'; *tmEventP = LookupTMEventType(eventTypeStr,error); if (*error) return PanicModeRecovery(str); event->event.eventType = events[*tmEventP].eventType; --- 749,764 ---- Boolean* error; { String start = str; ! char eventTypeStrbuf[100]; ! char* eventTypeStr; ScanAlphanumeric(str); + eventTypeStr = XtStackAlloc (str - start + 1, eventTypeStrbuf); + if (eventTypeStr == NULL) _XtAllocError (NULL); (void) memmove(eventTypeStr, start, str-start); eventTypeStr[str-start] = '\0'; *tmEventP = LookupTMEventType(eventTypeStr,error); + XtStackFree (eventTypeStr, eventTypeStrbuf); if (*error) return PanicModeRecovery(str); event->event.eventType = events[*tmEventP].eventType; *************** *** 938,948 **** Boolean* error; { char *start; ! char keySymName[100]; ScanWhitespace(str); if (*str == '\\') { str++; keySymName[0] = *str; if (*str != '\0' && *str != '\n') str++; --- 939,951 ---- Boolean* error; { char *start; ! char keySymNamebuf[100]; ! char* keySymName; ScanWhitespace(str); if (*str == '\\') { + keySymName = keySymNamebuf; str++; keySymName[0] = *str; if (*str != '\0' && *str != '\n') str++; *************** *** 954,959 **** --- 957,963 ---- * for backwards compatibility */ (*str == '(' && *(str+1) >= '0' && *(str+1) <= '9')) { + keySymName = keySymNamebuf; /* just so we can stackfree it later */ /* no detail */ event->event.eventCode = 0L; event->event.eventCodeMask = 0L; *************** *** 967,972 **** --- 971,977 ---- && *str != '\n' && (*str != '(' || *(str+1) <= '0' || *(str+1) >= '9') && *str != '\0') str++; + keySymName = XtStackAlloc (str - start + 1, keySymNamebuf); (void) memmove(keySymName, start, str-start); keySymName[str-start] = '\0'; event->event.eventCode = StringToKeySym(keySymName, error); *************** *** 980,985 **** --- 985,991 ---- "... possibly due to missing ',' in event sequence.", (String*)NULL, (Cardinal*)NULL); } + XtStackFree (keySymName, keySymNamebuf); return PanicModeRecovery(str); } if (event->event.standard) *************** *** 987,992 **** --- 993,1000 ---- else event->event.matchEvent = _XtMatchUsingDontCareMods; + XtStackFree (keySymName, keySymNamebuf); + return str; } *************** *** 1677,1682 **** --- 1685,1691 ---- if (newStr != NULL) { ParamPtr temp = (ParamRec*) ALLOCATE_LOCAL( (unsigned)sizeof(ParamRec) ); + if (temp == NULL) _XtAllocError (NULL); num_params++; temp->next = params; *************** *** 1775,1785 **** { Cardinal num_params = 1; String params[1]; ! int len = 499; ! char *eol, production[500]; eol = strchr(currentProduction, '\n'); ! if (eol) len = MIN(499, eol - currentProduction); (void) memmove(production, currentProduction, len); production[len] = '\0'; --- 1784,1797 ---- { Cardinal num_params = 1; String params[1]; ! int len; ! char *eol, *production, productionbuf[500]; eol = strchr(currentProduction, '\n'); ! if (eol) len = eol - currentProduction; ! else len = strlen (currentProduction); ! production = XtStackAlloc (len + 1, productionbuf); ! if (production == NULL) _XtAllocError (NULL); (void) memmove(production, currentProduction, len); production[len] = '\0'; *************** *** 1786,1791 **** --- 1798,1805 ---- params[0] = production; XtWarningMsg(XtNtranslationParseError, "showLine", XtCXtToolkitError, "... found while parsing '%s'", params, &num_params); + + XtStackFree (production, productionbuf); } /*********************************************************************** *** lib/Xaw/XawIm.c@@/main/R6.3-PATCH-2 Sat Nov 9 08:25:21 1996 --- xc/lib/Xaw/XawIm.c Tue Apr 21 07:36:06 1998 *************** *** 1,4 **** ! /* $XConsortium: XawIm.c /main/9 1996/11/09 08:20:50 kaleb $ */ /* * Copyright 1991 by OMRON Corporation --- 1,4 ---- ! /* $TOG: XawIm.c /main/9.0 1998/04/21 07:40:26 kaleb $ */ /* * Copyright 1991 by OMRON Corporation *************** *** 224,245 **** return(ve->ic.input_style); } - static XIMStyle GetInputStyleOfIM( p ) - String p; - { - if (!p || !*p) - return((XIMStyle)0); - if (!strcmp(p, "OverTheSpot")) { - return((XIMPreeditPosition | XIMStatusArea)); - } else if (!strcmp(p, "OffTheSpot")) { - return((XIMPreeditArea | XIMStatusArea)); - } else if (!strcmp(p, "Root")) { - return((XIMPreeditNothing | XIMStatusNothing)); - } else { - return((XIMStyle)0); - } - } - static void ConfigureCB( w, closure, event ) Widget w; XtPointer closure; --- 219,224 ---- *************** *** 389,402 **** if (contextErrData) XtFree((char *)contextErrData); } XDeleteContext(XtDisplay(vw), (Window)vw, extContext); - if (ve->im.im_list) { - XtFree((char *)ve->im.im_list[0]); - XtFree((char *)ve->im.im_list); - } - if (ve->ic.ic_list) { - XtFree((char *)ve->ic.ic_list[0]); - XtFree((char *)ve->ic.ic_list); - } if (ve->ic.shared_ic_table) XtFree((char *)ve->ic.shared_ic_table); if (ve->im.resources) XtFree((char *)ve->im.resources); --- 368,373 ---- *************** *** 438,462 **** static void OpenIM(ve) XawVendorShellExtPart * ve; { ! char *p, modifiers[32]; XIM xim = NULL; XIMStyles *xim_styles; ! XIMStyle input_style; ! int i, j; if (ve->im.open_im == False) return; ve->im.xim = NULL; ! if (ve->im.im_list_num <= 0) { if ((p = XSetLocaleModifiers("@im=none")) != NULL && *p) xim = XOpenIM(XtDisplay(ve->parent), NULL, NULL, NULL); } else { ! for (i = 0; i < ve->im.im_list_num; i++) { ! strcpy(modifiers, "@im="); ! strcat(modifiers, ve->im.im_list[i]); ! if ((p = XSetLocaleModifiers(modifiers)) != NULL && *p && ! (xim = XOpenIM(XtDisplay(ve->parent), NULL, NULL, NULL)) != NULL) break; } } if (xim == NULL) { if ((p = XSetLocaleModifiers("")) != NULL) { --- 409,456 ---- static void OpenIM(ve) XawVendorShellExtPart * ve; { ! int i; ! char *p, *s, *ns, *end, *pbuf, buf[32]; XIM xim = NULL; XIMStyles *xim_styles; ! XIMStyle input_style = 0; ! Boolean found; if (ve->im.open_im == False) return; ve->im.xim = NULL; ! if (ve->im.input_method == NULL) { if ((p = XSetLocaleModifiers("@im=none")) != NULL && *p) xim = XOpenIM(XtDisplay(ve->parent), NULL, NULL, NULL); } else { ! /* no fragment can be longer than the whole string */ ! int len = strlen (ve->im.input_method) + 5; ! ! if (len < sizeof buf) pbuf = buf; ! else pbuf = XtMalloc (len); ! ! if (pbuf == NULL) return; ! ! for(ns=s=ve->im.input_method; ns && *s;) { ! /* skip any leading blanks */ ! while (*s && isspace(*s)) s++; ! if (!*s) break; ! if ((ns = end = strchr(s, ',')) == NULL) ! end = s + strlen(s); ! /* strip any trailing blanks */ ! while (isspace(*end)) end--; ! ! strcpy (pbuf, "@im="); ! strncat (pbuf, s, end - s); ! pbuf[end - s + 4] = '\0'; ! ! if ((p = XSetLocaleModifiers(pbuf)) != NULL && *p ! && (xim = XOpenIM(XtDisplay(ve->parent), NULL, NULL, NULL)) != NULL) break; + + s = ns + 1; } + + if (pbuf != buf) XtFree (pbuf); } if (xim == NULL) { if ((p = XSetLocaleModifiers("")) != NULL) { *************** *** 475,498 **** XCloseIM(xim); return; } ! for (j = 0; j < ve->ic.ic_list_num; j++) { ! input_style = GetInputStyleOfIM(ve->ic.ic_list[j]); ! if (input_style == (XIMStyle)0) continue; ! for (i = 0; (unsigned short)i < xim_styles->count_styles; i++) { if (input_style == xim_styles->supported_styles[i]) { ve->ic.input_style = input_style; SetErrCnxt(ve->parent, xim); - /* _XipSetIOErrorHandler(IOErrorHandler); */ ve->im.xim = xim; ! XFree(xim_styles); ! return; } ! } } - XCloseIM(xim); - XtAppWarning(XtWidgetToApplicationContext(ve->parent), - "input method doesn't support my input style"); XFree(xim_styles); } static Boolean ResizeVendorShell_Core(vw, ve, p) --- 469,507 ---- XCloseIM(xim); return; } ! found = False; ! for(ns = s = ve->im.preedit_type; s && !found;) { ! while (*s && isspace(*s)) s++; ! if (!*s) break; ! if ((ns = end = strchr(s, ',')) == NULL) ! end = s + strlen(s); ! while (isspace(*end)) end--; ! ! if (!strncmp(s, "OverTheSpot", end - s)) { ! input_style = (XIMPreeditPosition | XIMStatusArea); ! } else if (!strncmp(s, "OffTheSpot", end - s)) { ! input_style = (XIMPreeditArea | XIMStatusArea); ! } else if (!strncmp(s, "Root", end - s)) { ! input_style = (XIMPreeditNothing | XIMStatusNothing); ! } ! for (i = 0; (unsigned short)i < xim_styles->count_styles; i++) if (input_style == xim_styles->supported_styles[i]) { ve->ic.input_style = input_style; SetErrCnxt(ve->parent, xim); ve->im.xim = xim; ! found = True; ! break; } ! ! s = ns + 1; } XFree(xim_styles); + + if (!found) { + XCloseIM(xim); + XtAppWarning(XtWidgetToApplicationContext(ve->parent), + "input method doesn't support my input style"); + } } static Boolean ResizeVendorShell_Core(vw, ve, p) *************** *** 1338,1385 **** #undef xrmres } - - static char** ParseIMNameList(p, num) - char* p; - int* num; - { - char *s, *save_s, *ss, *list[32], **lp, *end; - int i = 0; - - *num = 0; - if (!p || !*p) return ((char **)NULL); - while (*p && isspace(*p)) p++; - if (!*p) return ((char **)NULL); - if ((s = XtMalloc(strlen(p) + 1)) == NULL) return((char **)NULL); - strcpy(s, p); - save_s = s; - - while(1) { - list[i] = s; - ss = index(s, ','); - if (!ss) { - end = s + strlen(s); - } else { - end = ss; - } - while (isspace(*end)) end--; - *end = '\0'; - i++; - if (!ss) break; - s = ss + 1; - while (*s && isspace(*s)) p++; - if (!*s) break; - } - if ((lp = (char **)XtMalloc(sizeof(char *) * (i + 1))) == NULL) { - XtFree(save_s); - return((char **)NULL); - } - memcpy((char *)lp, (char *)list, sizeof(char *) * i); - *(lp + i) = NULL; - *num = i; - return(lp); - } - static Boolean Initialize( vw, ve ) VendorShellWidget vw; XawVendorShellExtPart* ve; --- 1347,1352 ---- *************** *** 1400,1409 **** return(FALSE); ve->ic.current_ic_table = NULL; ve->ic.ic_table = NULL; - ve->im.im_list = ParseIMNameList(ve->im.input_method, &i); - ve->im.im_list_num = i; - ve->ic.ic_list = ParseIMNameList(ve->im.preedit_type, &i); - ve->ic.ic_list_num = i; return(TRUE); } --- 1367,1372 ---- *** lib/Xaw/XawImP.h@@/main/R6.3-PATCH-2 Fri Dec 8 16:35:05 1995 --- xc/lib/Xaw/XawImP.h Tue Apr 21 09:40:14 1998 *************** *** 1,4 **** ! /* $XConsortium: XawImP.h /main/5 1995/12/08 16:34:32 kaleb $ */ /* * Copyright 1991 by OMRON Corporation --- 1,4 ---- ! /* $TOG: XawImP.h /main/5.0 1998/04/21 09:44:31 kaleb $ */ /* * Copyright 1991 by OMRON Corporation *************** *** 85,92 **** Dimension area_height; String input_method; String preedit_type; - String *im_list; - Cardinal im_list_num; } XawImPart; typedef struct _XawIcTablePart --- 80,85 ---- *************** *** 109,116 **** typedef struct _XawIcPart { - String *ic_list; - Cardinal ic_list_num; XIMStyle input_style; Boolean shared_ic; XawIcTableList shared_ic_table; --- 102,107 ---- *** programs/xterm/charproc.c@@/main/R6.3-PATCH-2 Tue Dec 3 16:52:49 1996 --- xc/programs/xterm/charproc.c Thu Apr 9 15:36:00 1998 *************** *** 1,4 **** /* ! * $XConsortium: charproc.c /main/196 1996/12/03 16:52:46 swick $ */ --- 1,4 ---- /* ! * $TOG: charproc.c /main/196.0 1998/04/09 15:39:26 kaleb $ */ *************** *** 2669,2675 **** *s, *ns, *end, ! tmp[1024], buf[32]; XIM xim = (XIM) NULL; XIMStyles *xim_styles; --- 2664,2670 ---- *s, *ns, *end, ! *pbuf, buf[32]; XIM xim = (XIM) NULL; XIMStyles *xim_styles; *************** *** 2684,2706 **** 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;) { 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 ((p = XSetLocaleModifiers(buf)) != NULL && *p && (xim = XOpenIM(XtDisplay(term), NULL, NULL, NULL)) != NULL) break; s = ns + 1; } } if (xim == NULL && (p = XSetLocaleModifiers("")) != NULL) --- 2679,2713 ---- if ((p = XSetLocaleModifiers("@im=none")) != NULL && *p) xim = XOpenIM(XtDisplay(term), NULL, NULL, NULL); } else { ! /* no fragment can be longer than the whole string */ ! int len = strlen (term->misc.input_method) + 5; ! ! if (len < sizeof buf) pbuf = buf; ! else pbuf = malloc (len); ! ! if (pbuf == NULL) ! SysError(ERROR_VINIT); ! ! for(ns=s=term->misc.input_method; ns && *s;) { ! /* skip any leading blanks */ while (*s && isspace(*s)) s++; if (!*s) break; ! if ((ns = end = strchr(s, ',')) == NULL) end = s + strlen(s); + /* strip any trailing blanks */ while (isspace(*end)) end--; ! strcpy (pbuf, "@im="); ! strncat (pbuf, s, end - s); ! pbuf[end - s + 4] = '\0'; ! ! if ((p = XSetLocaleModifiers(pbuf)) != NULL && *p && (xim = XOpenIM(XtDisplay(term), NULL, NULL, NULL)) != NULL) break; s = ns + 1; } + if (pbuf != buf) free (pbuf); } if (xim == NULL && (p = XSetLocaleModifiers("")) != NULL) *************** *** 2719,2740 **** } found = False; ! strcpy(tmp, term->misc.preedit_type); ! for(s = tmp; s && !found;) { while (*s && isspace(*s)) s++; if (!*s) break; ! if (ns = end = index(s, ',')) ! ns++; ! else end = s + strlen(s); while (isspace(*end)) end--; - *end = '\0'; ! if (!strcmp(s, "OverTheSpot")) { input_style = (XIMPreeditPosition | XIMStatusArea); ! } else if (!strcmp(s, "OffTheSpot")) { input_style = (XIMPreeditArea | XIMStatusArea); ! } else if (!strcmp(s, "Root")) { input_style = (XIMPreeditNothing | XIMStatusNothing); } for (i = 0; (unsigned short)i < xim_styles->count_styles; i++) --- 2726,2743 ---- } found = False; ! for(ns = s = term->misc.preedit_type; s && !found;) { while (*s && isspace(*s)) s++; if (!*s) break; ! if ((ns = end = strchr(s, ',')) == NULL) end = s + strlen(s); while (isspace(*end)) end--; ! if (!strncmp(s, "OverTheSpot", end - s)) { input_style = (XIMPreeditPosition | XIMStatusArea); ! } else if (!strncmp(s, "OffTheSpot", end - s)) { input_style = (XIMPreeditArea | XIMStatusArea); ! } else if (!strncmp(s, "Root", end - s)) { input_style = (XIMPreeditNothing | XIMStatusNothing); } for (i = 0; (unsigned short)i < xim_styles->count_styles; i++) *************** *** 2743,2749 **** break; } ! s = ns; } XFree(xim_styles); --- 2746,2752 ---- break; } ! s = ns + 1; } XFree(xim_styles); *************** *** 3173,3178 **** --- 3176,3184 ---- }; char mapName[1000]; char mapClass[1000]; + char* pmapName; + char* pmapClass; + int len; if (*param_count != 1) return; *************** *** 3182,3191 **** XtOverrideTranslations(w, original); return; } ! (void) sprintf( mapName, "%sKeymap", params[0] ); ! (void) strcpy( mapClass, mapName ); ! if (islower(mapClass[0])) mapClass[0] = toupper(mapClass[0]); ! XtGetSubresources( w, (XtPointer)&keymap, mapName, mapClass, key_resources, (Cardinal)1, NULL, (Cardinal)0 ); if (keymap != NULL) XtOverrideTranslations(w, keymap); --- 3188,3211 ---- XtOverrideTranslations(w, original); return; } ! ! len = strlen (params[0]) + 7; ! ! if (len < sizeof mapName) { ! pmapName = mapName; ! pmapClass = mapClass; ! } else { ! pmapName = malloc (len); ! pmapClass = malloc (len); ! ! if (pmapName == NULL || pmapClass == NULL) ! SysError(57); ! } ! ! (void) sprintf( pmapName, "%sKeymap", params[0] ); ! (void) strcpy( pmapClass, pmapName ); ! if (islower(pmapClass[0])) pmapClass[0] = toupper(pmapClass[0]); ! XtGetSubresources( w, (XtPointer)&keymap, pmapName, pmapClass, key_resources, (Cardinal)1, NULL, (Cardinal)0 ); if (keymap != NULL) XtOverrideTranslations(w, keymap);