From: Tor Lillqvist Date: Wed, 8 Oct 2008 20:35:39 +0000 (+0000) Subject: Bug 554790 - g_convert() misbehaves with winiconv versions X-Git-Tag: GLIB_2_19_0~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c7501c82237380bbe03646e6f4133b4862bec5a8;p=platform%2Fupstream%2Fglib.git Bug 554790 - g_convert() misbehaves with winiconv versions 2008-10-08 Tor Lillqvist 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. svn path=/trunk/; revision=7578 --- diff --git a/ChangeLog b/ChangeLog index 2ae8d23..9bf3daf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-10-08 Tor Lillqvist + + 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. + 2008-10-06 Matthias Clasen * glib/gtypes.h: Properly include gmacros.h diff --git a/glib/win_iconv.c b/glib/win_iconv.c index b8ee710..ea19240 100644 --- a/glib/win_iconv.c +++ b/glib/win_iconv.c @@ -1362,6 +1362,12 @@ kernel_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wb 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)