|
Message-ID: <CAJgzZoqQv5=mCLTqs5EP7314f9bVH_vzLQ-6toh2-RmMs=RcJQ@mail.gmail.com>
Date: Wed, 21 Jun 2023 15:10:26 -0700
From: enh <enh@...gle.com>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] [RFC] trap on invalid printf formats
i really should do this in bionic... currently we only abort on %n (which
is explicitly _not_ supported) or %w with a silly size.
for random junk, we currently do what the BSDs do (since that's where this
code originally came from):
default: /* "%?" prints ?, unless ? is NUL */
if (ch == '\0') goto done;
/* pretend it was %c with argument ch */
cp = buf;
*cp = ch;
size = 1;
sign = '\0';
break;
from running a quick test program, macOS and glibc seem to work similarly,
which increases the chances that there's incorrect code out there. (clang
does at least warn "warning: invalid conversion specifier '?'
[-Wformat-invalid-specifier]" by default, though. gcc doesn't.)
On Wed, Jun 21, 2023 at 2:38 PM Rich Felker <dalias@...c.org> wrote:
> Inspired by a new instance of some bitrotted software using %Lu
> instead of %llu, attached is a draft patch to catch such errors rather
> than silently leaving missing output.
>
> I don't know if this is a good idea to actually do (note: probably
> matching changes should be made in wide printf and maybe also scanf if
> so) but I'm posting it here in case anyone wants to experiment or
> discuss. Note that there is no conformance distinction since invalid
> format strings are undefined behavior.
>
> Rich
>
Content of type "text/html" skipped
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.