Ticket #820 (closed defect: Fixed)
[freebsd] 1.3.2 crash on iconv conversion
| Reported by: | nightmar | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | None | Version: | |
| Keywords: | Cc: |
Description
on FreeBSD system (both 5.x and 6.x versions)
there is a problem with libiconv, which does not like encoding names with spaces inside -- like "CP 1251" and wish to get "CP1251" from calling program. So, if recipient, to whom you send message, have such encoding and licq shoudl do transform from UCS16 to 8-bit encoding it gets -1 from iconv_open
(man says
The iconv_open function returns a freshly
allocated conversion descrip-
tor. In case of error, it sets errno and returns
(iconv_t)(-1).
)
and program crashes on iconv call.
There is NO checks of return value of iconv_open() in translate.cpp at all.
I've applied following patch to one place in translate.cpp which caused problems to me, may be it's necessary to add something like this to another places too. probably this should be ifdef-ed to run only on freebsd
--cut-- 349c349,360 < size_t ret = iconv(tr, &szIn, &nInSize, &szOut, &nOutSize); ---
if (tr == (iconv_t)(-1)) { char *_bsd_pos = strchr(_szEncoding, ' '); int _bsd_sz = strlen(_szEncoding); if (_bsd_pos!= NULL) { strncpy(_bsd_pos, _bsd_pos+1, _bsd_sz -
(_bsd_pos - _szEncoding));
} tr = iconv_open("UCS-2BE", _szEncoding); } size_t ret = iconv(tr, (const char**)&szIn,
&nInSize, &szOut, &nOutSize); --cut--
this fixed problem for me ;)
