glib r7577 - in branches/glib-2-18: . glib



Author: tml
Date: Wed Oct  8 20:34:46 2008
New Revision: 7577
URL: http://svn.gnome.org/viewvc/glib?rev=7577&view=rev

Log:
2008-10-08  Tor Lillqvist  <tml novell com>

	Bug 554790 - g_convert() misbehaves with winiconv versions

	* glib/win_iconv.c (kernel_mbtowc): If converting from ASCII,
	explicitly check for and reject 8bit chars. MultiByteToWideChar()
	doesn't, at least not on XP.



Modified:
   branches/glib-2-18/ChangeLog
   branches/glib-2-18/glib/win_iconv.c

Modified: branches/glib-2-18/glib/win_iconv.c
==============================================================================
--- branches/glib-2-18/glib/win_iconv.c	(original)
+++ branches/glib-2-18/glib/win_iconv.c	Wed Oct  8 20:34:46 2008
@@ -1362,6 +1362,12 @@
     len = cv->mblen(cv, buf, bufsize);
     if (len == -1)
         return -1;
+    /* If converting from ASCII, reject 8bit
+     * chars. MultiByteToWideChar() doesn't. Note that for ASCII we
+     * know that the mblen function is sbcs_mblen() so len is 1.
+     */
+    if (cv->codepage == 20127 && buf[0] >= 0x80)
+        return_error(EILSEQ);
     *wbufsize = MultiByteToWideChar(cv->codepage, mbtowc_flags (cv->codepage),
             (const char *)buf, len, (wchar_t *)wbuf, *wbufsize);
     if (*wbufsize == 0)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]