From winard@ritax.dorm.ccu.edu.tw  Sat Apr 13 01:36:10 2002
Return-Path: <winard@ritax.dorm.ccu.edu.tw>
Received: from ritax.dorm.ccu.edu.tw (ritax.dorm.ccu.edu.tw [140.123.11.79])
	by hub.freebsd.org (Postfix) with SMTP id 527C537B405
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 13 Apr 2002 01:36:02 -0700 (PDT)
Received: (qmail 90044 invoked by uid 1001); 13 Apr 2002 08:35:12 -0000
Message-Id: <20020413083512.90043.qmail@ritax.dorm.ccu.edu.tw>
Date: 13 Apr 2002 08:35:12 -0000
From: Yong-Jhen Hong <winard@ritax.dorm.ccu.edu.tw>
Reply-To: Yong-Jhen Hong <winard@ms11.url.com.tw>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Fixed maximum character length in EUC
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         37034
>Category:       conf
>Synopsis:       Fixed maximum character length in EUC
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Apr 13 01:40:01 PDT 2002
>Closed-Date:    Sun Apr 10 12:47:42 GMT 2005
>Last-Modified:  Sun Apr 10 12:47:42 GMT 2005
>Originator:     Yong-Jhen Hong
>Release:        FreeBSD 4.5-STABLE i386
>Organization:
N/A
>Environment:
System: FreeBSD ritax.dorm.ccu.edu.tw 4.5-STABLE FreeBSD 4.5-STABLE #0: Tue Mar 19 03:06:46 CST 2002 toor@ritax.dorm.ccu.edu.tw:/usr/obj/usr/src/sys/RITAX i386


>Description:
The EUC rune-related functions use a fixed maximum character length,
which forbids longer multibyte characters.

>How-To-Repeat:
Create a EUC encoding LC_CTYPE locale file which has codeset(s)
longer than three bytes, use mbtowc(3) to convert such multibyte
words.

>Fix:
Apply the following patch:

--- patch-euc begins here ---
--- euc.c       Mon Jun  5 05:47:39 2000
+++ euc.c.new   Thu Mar 28 15:19:02 2002
@@ -82,6 +82,7 @@
                free(rl);
                return (ENOMEM);
        }
+       __mb_cur_max = 0;
        for (x = 0; x < 4; ++x) {
                ei->count[x] = (int) strtol(v, &e, 0);
                if (v == e || !(v = e)) {
@@ -89,6 +90,8 @@
                        free(ei);
                        return (EFTYPE);
                }
+               if (__mb_cur_max < ei->count[x])
+                       __mb_cur_max = ei->count[x];
                while (*v == ' ' || *v == '\t')
                        ++v;
                ei->bits[x] = (int) strtol(v, &e, 0);
@@ -114,7 +117,6 @@
        }
        rl->variable_len = sizeof(_EucInfo);
        _CurrentRuneLocale = rl;
-       __mb_cur_max = 3;
        return (0);
 }

--- patch-euc ends here ---

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: leeym 
State-Changed-When: Sun Apr 10 12:45:59 GMT 2005 
State-Changed-Why:  
Fixed by asmodai@ in rev 1.8 
http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/locale/euc.c.diff?r1=1.7&r2=1.8&f=h 

and refined by ache@ in rev 1.10 
http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/locale/euc.c.diff?r1=1.9&r2=1.10&f=h 


http://www.freebsd.org/cgi/query-pr.cgi?pr=37034 
>Unformatted:
