delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/07/28/06:20:49

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Tue, 28 Jul 2009 12:20:24 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: bug in mbrtowc?
Message-ID: <20090728102024.GN18621@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <416096c60907271456x5e8cb3f7y64433d542ec6cdcb AT mail DOT gmail DOT com> <20090728091413 DOT GJ18621 AT calimero DOT vinschen DOT de> <94b5b62d0907280250q3321f62ft6cc542367dbc68d2 AT mail DOT gmail DOT com> <416096c60907280256k18d164cy7fcd976b6c32383f AT mail DOT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <416096c60907280256k18d164cy7fcd976b6c32383f@mail.gmail.com>
User-Agent: Mutt/1.5.19 (2009-02-20)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Jul 28 10:56, Andy Koppe wrote:
> 2009/7/28 Pedro Izecksohn:
> >  The bug is in O.P.'s code as &s is not being passed to mbrtowc.
> 
> >From http://www.opengroup.org/onlinepubs/009695399/functions/mbrtowc.html:
> "If ps is a null pointer, the mbrtowc() function shall use its own
> internal mbstate_t object, which shall be initialized at program
> start-up to the initial conversion state."
> 
> The test also fails when passing &s instead. (I'd accidentally left in
> the local mb_state.)

Yes, I checked that as well.  It doesn't matter if the internal or
the `s' state is used.  The problm is actually in __utf8_mbtowc.
It doesn't count a variable correctly which in turn results in reading
too much of the input if a the followup sequence of an incomplete
sequence is itself an incomplete sequence.  My patch sent to the
newlib list (http://sourceware.org/ml/newlib/2009/msg00778.html)
fixes that.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019