Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJgzZoq0+-vS9jm7bz=LvK-ai4uhQtGN7yc5Z8TwfzkPdTMh5w@mail.gmail.com>
Date: Tue, 2 Aug 2022 09:26:45 -0700
From: enh <enh@...gle.com>
To: libc-coord@...ts.openwall.com
Subject: Re: anyone else working on %b?

On Fri, Jul 29, 2022 at 4:21 PM enh <enh@...gle.com> wrote:
>
> On Fri, Jul 29, 2022 at 3:21 PM Joseph Myers <joseph@...esourcery.com> wrote:
> >
> > On Fri, 29 Jul 2022, enh wrote:
> >
> > > i've wanted %b (along with 0b literals) for decades now, and i'm
> > > wondering if anyone else already has %b implemented, so i can use that
> > > as precedent to justify shipping bionic's implementation before the
> > > standard is final?
> >
> > I implemented printf %b and %B for glibc 2.35, and GCC 12 format checking.
>
> awesome! i'll check clang more closely in that case then... maybe it's
> already there but i didn't set -std=. otherwise i'll use gcc as
> precedent to get that into clang :-)

nope, still not supported in clang. i've filed
https://github.com/llvm/llvm-project/issues/56885 for the missing
clang support for these in format strings, and i'll hassle our
compiler folks to actually fix it.

https://android-review.googlesource.com/c/platform/bionic/+/2169037
adds %b/%B to bionic's printf/wprintf family. i'll do
scanf/wscanf/strto* separately since (a) i've never needed those like
i've needed printf and (b) they might be trickier to land given the
behavior change.

> > (The format checking also supports scanf %b.  I haven't yet implemented
> > scanf %b in glibc; scanf is more complicated than printf here because it
> > comes with changes to strtol, and scanf %i, which mean 32, 44 or 56 new
> > function variants in glibc depending on the architecture, as described in
> > <https://sourceware.org/pipermail/libc-alpha/2020-December/120414.html>,
> > to keep proper compatibility with different standard versions.)
>
> interesting. for no reason other than "i've never wanted it, so it was
> last on my list", scanf() is the only part i haven't implemented yet.
> i hadn't thought about that...
>
> in terms of what's in the headers bionic takes the unusual stance of
> "you get whatever's available at your OS version" and mostly ignores
> the -std= version. (why? because people struggle enough reasoning
> about the OS version [which is unavoidable] without having _multiple_
> dimensions of "do i have this thing?". it's not an ideal stance for
> experts, but experts are a lot better at getting themselves out of
> mischief.)
>
> but i'm not sure we've had a standard-specific _behavior_ before? the
> closest i can remember is stuff like the GNU %m extensions (either the
> printf %m errno one or the scanf %ms one). i'm assuming you never did
> the experiment of enabling 0b/0B for everyone, so you don't know
> whether anything broke?
>
> > --
> > Joseph S. Myers
> > joseph@...esourcery.com

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.