--- XawIm.c.orig	Sat Jan 11 18:14:44 1997
+++ XawIm.c	Sat Jul 25 13:02:03 1998
@@ -53,6 +53,7 @@
 in this Software without prior written authorization from the X Consortium.
 
 */
+/* $XFree86: xc/lib/Xaw/XawIm.c,v 1.1.1.4.2.1 1998/05/01 04:02:42 dawes Exp $ */
 
 #include <X11/IntrinsicP.h>
 #include <X11/StringDefs.h>
@@ -427,7 +428,7 @@
     } else {
 	for (i = 0; i < ve->im.im_list_num; i++) {
 	    strcpy(modifiers, "@im=");
-	    strcat(modifiers, ve->im.im_list[i]);
+	    strncat(modifiers, ve->im.im_list[i], sizeof(modifiers) - 5/*strlen("@im=")*/);
 	    if ((p = XSetLocaleModifiers(modifiers)) != NULL && *p &&
 		(xim = XOpenIM(XtDisplay(ve->parent), NULL, NULL, NULL)) != NULL)
 		break;
@@ -1329,7 +1330,7 @@
     strcpy(s, p);
     save_s = s;
 
-    while(1) {
+    while(i < (sizeof(list) / sizeof(list[0]))) {
 	list[i] = s;
 	ss = index(s, ',');
 	if (!ss) {
@@ -1676,10 +1677,10 @@
 
     if ((vw = SearchVendorShell(inwidg)) && (ve = GetExtPart(vw)) &&
 	ve->im.xim && (p = GetIcTableShared(inwidg, ve)) && p->xic) {
-	  return(XwcLookupString(p->xic, event, buffer_return, bytes_buffer,
+	  return(XwcLookupString(p->xic, event, buffer_return, bytes_buffer/sizeof(wchar_t),
 				 keysym_return, status_return));
     }
-    ret = XLookupString( event, tmp_buf, 64, keysym_return,
+    ret = XLookupString( event, tmp_buf, sizeof(tmp_buf), keysym_return,
 		         (XComposeStatus*) status_return );
     for ( i = 0, tmp_p = tmp_buf, buf_p = buffer_return; i < ret; i++ ) {
 	*buf_p++ = _Xaw_atowc(*tmp_p++);
