From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26040 invoked by alias); 27 Feb 2003 03:36:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 26018 invoked by uid 71); 27 Feb 2003 03:36:00 -0000 Resent-Date: 27 Feb 2003 03:36:00 -0000 Resent-Message-ID: <20030227033600.26017.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, jon@biggar.org Received: (qmail 25631 invoked by uid 48); 27 Feb 2003 03:32:10 -0000 Message-Id: <20030227033210.25630.qmail@sources.redhat.com> Date: Thu, 27 Feb 2003 03:36:00 -0000 From: jon@biggar.org Reply-To: jon@biggar.org To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: libstdc++/9870: ctype::do_widen(char) is broken X-SW-Source: 2003-02/txt/msg01404.txt.bz2 List-Id: >Number: 9870 >Category: libstdc++ >Synopsis: ctype::do_widen(char) is broken >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Thu Feb 27 03:36:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: Jonathan Biggar >Release: gcc 3.2 >Organization: >Environment: >Description: The current implementation of ctype::do_widen(char) is broken, because it uses btowc. The glibc man page for btowc already states that this function should never be used because it doesn't handle stateful or multibyte character encodings well. Also, since btowc takes an int argument, calling it with a char value on machines that use signed char improperly sign extends the argument, which causes an incorrect result to be returned. For example, calling do_widen(0xFF) in an ISO8859-1 locale returns -1, rather than the correct 0xFF. >How-To-Repeat: call do_widen() with a signed char value between 0x80 and 0xFF. >Fix: do_widen(char) should use mbsrtowcs, like the array based version does. >Release-Note: >Audit-Trail: >Unformatted: