Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 10 Sep 2019 13:33:51 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: printf doesn't respect locale

On Tue, Sep 10, 2019 at 06:10:20PM +0100, Daniel Schoepe wrote:
> Basically, someone used printf to produce json output and was unaware
> that the radix used by printf was locale-dependent. When this was run
> on a system with a non-English locale, it no longer produced valid
> JSON as output.

Yes, like you say it's not really a bug in correct software so much as
a pitfall programmers are unaware of, that's hard to program around.

But it can actually be a bug in correct *application* software due to
incorrect library software. Various library software (I think glib or
gtk, IIRC, among many others) calls setlocale(LC_ALL,"") behind the
application's back, rather than trusting that the application set the
locale the way it wants (incidentially, this is not thread-safe or
library-safe and makes these libraries unsafe to use via dlopen or
anywhere but at the top of main!). If the application only intends to
set other categories, but leave LC_NUMERIC as "C", then it should
rightfully expect a '.' radix point, but this expectation will be
violated if certain third-party libraries are involved.

Rich

> On Tue, Sep 10, 2019 at 5:31 PM Szabolcs Nagy <nsz@...t70.net> wrote:
> >
> > * Daniel Schoepe <daniel@...oepe.org> [2019-09-10 17:00:49 +0100]:
> > > I'm also not a fan of this behavior, I actually stumbled across this
> > > when tracking
> > > down a bug the different radix usage caused.
> >
> > i'm interested in how this can cause a bug in correct software.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.