Date: Mon, 25 Nov 2002 10:38:42 +0800 (CST) From: Cheng-Lung Sung <AlanSung@alansung.dragon2.net> To: FreeBSD-gnats-submit@FreeBSD.org Cc: clsung@dragon2.net Subject: ports/45697: [PATCH] centericq fix core dump with MSN UTF-8 Message-ID: <200211250238.gAP2cgo4028902@alansung.dragon2.net>
next in thread | raw e-mail | index | archive | help
>Number: 45697 >Category: ports >Synopsis: [PATCH] centericq fix core dump with MSN UTF-8 >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Nov 24 18:40:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Cheng-Lung Sung <clsung@dragon2.net> >Release: FreeBSD 4.7-RELEASE i386 >Organization: NCTU CSIE FreeBSD Server >Environment: System: FreeBSD AlanSung.dragon2.net 4.7-RELEASE FreeBSD 4.7-RELEASE #1: Fri Oct 11 14:23:08 CST 2002 root@AlanSung.dragon2.net:/usr/obj/usr/src/sys/SungSung i386 gnu iconv library needed >Description: previous patch will lead to core dump, when use MSN with locale (default, ISO-8859-1), this patch fix this problem >How-To-Repeat: When your LANG setting contains no dot "." , it will cause Segmantain fault(ocore dump) when send/receive msg. >Fix: diff -ruN /usr/ports/net/centericq/files/patch-msnhook.cc centericq/files/patch-msnhook.cc --- /usr/ports/net/centericq/files/patch-msnhook.cc Wed Nov 20 23:19:23 2002 +++ centericq/files/patch-msnhook.cc Mon Nov 25 10:22:27 2002 @@ -1,5 +1,5 @@ ---- src/hooks/msnhook.cc Tue Nov 19 10:18:22 2002 -+++ src/hooks/msnhook.cc Tue Nov 19 10:18:35 2002 +--- src/hooks/msnhook.cc Mon Nov 24 10:16:27 2002 ++++ src/hooks/msnhook.cc Mon Nov 25 10:16:27 2002 @@ -30,6 +30,7 @@ #include "eventmanager.h" #include "centericq.h" @@ -39,7 +39,7 @@ em.store(immessage(ic, imevent::incoming, text)); if(c) -@@ -453,3 +456,121 @@ +@@ -453,3 +456,132 @@ clist.get(contactroot)->playsound(imevent::email); } } @@ -68,11 +68,12 @@ + return loc_charset; + + lang = getenv("LANG"); -+ ch = strrchr( lang, '.' ) + 1; ++ ch = strrchr( lang, '.' ); + if (!ch) + strcpy( loc_charset, DEFAULT_CHARSET ); + else { + iconv_t pt; ++ ch++; + strncpy( loc_charset, ch, sizeof(loc_charset) ); + /* try to open iconv handle using guessed charset */ + if ( (pt = iconv_open( loc_charset, loc_charset )) == (iconv_t)(-1) ) @@ -96,12 +97,15 @@ + int ret; + + iconv_t handle = iconv_open( "utf-8", guess_current_locale_charset() ); -+ ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength ); ++ if(((int) handle) != -1) { ++ ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength ); + -+ *outbuf = '\0'; -+ iconv_close( handle ); -+ -+ return outbuf_save; ++ *outbuf = '\0'; ++ iconv_close( handle ); ++ return outbuf_save; ++ } else { ++ return (char *)inbuf; ++ }; +} + +std::string StrToUtf8( const std::string &instr ) @@ -114,13 +118,17 @@ + int ret; + + iconv_t handle = iconv_open( "utf-8", guess_current_locale_charset() ); -+ ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength ); ++ if(((int) handle) != -1) { ++ ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength ); + -+ *outbuf = '\0'; -+ iconv_close( handle ); ++ *outbuf = '\0'; ++ iconv_close( handle ); + -+ std::string return_me = outbuf_save; -+ return return_me; ++ std::string return_me = outbuf_save; ++ return return_me; ++ } else { ++ return instr; ++ }; +} + +char *Utf8ToStr( const char *inbuf ) @@ -132,13 +140,14 @@ + int ret; + + iconv_t handle = iconv_open( guess_current_locale_charset(), "utf-8" ); -+ -+ ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength ); -+ -+ *outbuf = '\0'; -+ iconv_close( handle ); -+ -+ return outbuf_save; ++ if(((int) handle) != -1) { ++ ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength ); ++ *outbuf = '\0'; ++ iconv_close( handle ); ++ return outbuf_save; ++ } else { ++ return (char *)inbuf; ++ }; +} + +std::string Utf8ToStr( const std::string &instr ) @@ -152,12 +161,14 @@ + + iconv_t handle = iconv_open( guess_current_locale_charset(), "utf-8" ); + -+ ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength ); -+ -+ *outbuf = '\0'; -+ iconv_close( handle ); -+ -+ std::string return_me = outbuf_save; -+ return return_me; ++ if(((int) handle) != -1) { ++ ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength ); ++ *outbuf = '\0'; ++ iconv_close( handle ); ++ std::string return_me = outbuf_save; ++ return return_me; ++ } else { ++ return instr; ++ }; +} +#endif /* HAVE_ICONV_H */ >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200211250238.gAP2cgo4028902>