Bug 14812 - Crash because of misusing iconv (uim-1.4.2 and older)
Summary: Crash because of misusing iconv (uim-1.4.2 and older)
Status: RESOLVED FIXED
Alias: None
Product: UIM
Classification: Unclassified
Component: bridge: XIM (show other bugs)
Version: unspecified
Hardware: All All
: medium critical
Assignee: uim-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-04 13:14 UTC by G-HAL
Modified: 2008-03-06 06:40 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
patch, for fix the problem. (2.75 KB, patch)
2008-03-04 13:14 UTC, G-HAL
Details | Splinter Review

Description G-HAL 2008-03-04 13:14:54 UTC
Created attachment 14821 [details] [review]
patch, for fix the problem.

uim-xim sometimes cause crash, because of misuse of iconv.
Relevant version is uim-1.4.2 and older versions.

1)
A string returned by iconv() is not ASCIIZ.
The end of string is not a charactor '\x0'.

2)
It is required that calling iconv() with inbuf = NULL, inbytesleft = NULL to finish a session of conversion.
Comment 1 Etsushi Kato 2008-03-04 20:53:47 UTC
Thanks for the report.  I've forgot to backport the termination issue of uim-xim to 1.4.2, sorry.

But I'm just curious to know that is resetting iconv state really needed?  I'm too ignorant about iconv(3).  Any pointer about this?
Comment 2 G-HAL 2008-03-05 15:02:07 UTC
Sorry, I make a mistake.
If uim use only UTF-8, EUC-JP and ShiftJIS(cp932),
resetting the state is specially unnecessary, probably.
I forgot to check whether it was able to be applied to uim or not.
Ummm...
Excuse me but I have no idea that there are any OS or emacs-el that uses ISO-2022-JP for locale in OS or encoding in emacs-el.


Anyway, in generally, resetting a state is required when using iconv.
I do not found a document clearly described.
But some documents said implicitly.

In libiconv-1.11, testing code and command-line tool.
libiconv-1.11/tests/table-from.c: line from 56 to 58
libiconv-1.11/tests/table-to.c: line from 70 to 72
libiconv-1.11/src/iconv.c: ... so many, snip.

Sun docs, man pages section 3 iconv(3c).
In example, resetting a state using INIT_SHIFT_STATE() macro.
http://docs.sun.com/app/docs/doc/819-2243/iconv-3c?l=ja&a=view


Thank you.
Comment 3 Etsushi Kato 2008-03-06 06:40:05 UTC
Thanks, libiconv's example is interesting.  And now the patch is applied to svn trunk.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.