[Uim] fix xim/locale.cpp

IWATA Ray iwata at quasiquote.org
Wed Feb 14 19:49:04 EET 2007


Hi,

UTF8_Locale::utf8_to_native_str() has
off-by-one and unterminated string, which may cause a crash.

--- old-uim/xim/locale.cpp	Thu Feb 15 02:37:41 2007
+++ new-uim/xim/locale.cpp	Thu Feb 15 02:37:41 2007
@@ -267,7 +267,7 @@
     if (!m_iconv_cd)
 	return strdup(inbuf);
 
-    outbuf = (char *)malloc(outbufsize);
+    outbuf = (char *)malloc(outbufsize + 1);
     if (!outbuf)
 	return NULL;
 
@@ -288,6 +288,8 @@
 	free(outbuf);
 	return NULL;
     }
+
+    *outchar = 0;
 
     strlcpy(convstr, outbuf, outbufsize - outbytesleft + 1);
     free(outbuf);

----
Iwata




More information about the uim mailing list