From: "Alex Xu (Hello71)" <alex_y_xu@yahoo.ca>
To: musl@lists.openwall.com
Cc: Markus Wichmann <nullplan@gmx.net>, Rich Felker <dalias@libc.org>
Subject: Re: [musl] [PATCH] [RFC] trap on invalid printf formats
Date: Thu, 22 Jun 2023 19:37:22 -0400 [thread overview]
Message-ID: <1687470871.bzv5u1iuij.none@localhost> (raw)
In-Reply-To: <20230622144550.GN4163@brightrain.aerifal.cx>
Excerpts from Rich Felker's message of June 22, 2023 10:45 am:
> FWIW I don't think there are a lot of these cases left in the wild at
> all, but I'm not sure. it might be nice to do some distro-wide testing
> with this patch applied (which is what I had in mind posting it) and
> see if any problems are caught before really considering whether to
> pursue upstreaming it.
Unfortunately, it seems fairly widespread:
https://codesearch.debian.net/search?q=printf.*%5B%25%5DL%5Bud%5D+-package%3Agcc+-package%3Allvm*+path%3A.*%5C.c%24&literal=0
The most painful example:
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__APPLE_CC__) || defined(__APPLE__) || defined(ARGUS_SOLARIS)
sprintf (pbuf, "%llu", value);
#else
sprintf (pbuf, "%Lu", value);
#endif
(copied and pasted 17 times in the same file, of course)
I did some research and the most likely source of %Lu is the Linux
man-pages, which, before 1999 or thereabouts, said:
> • The optional character l (ell) specifying that a following d, i, o,
> u, x, or X conversion applies to a pointer to a long int or unsigned
> long int argument, or that a following n conversion corresponds to a
> pointer to a long int argument. Linux provides a non ANSI compliant
> use of two l flags as a synonym to q or L. Thus ll can be used in
> combination with float conversions. *This usage is, however, strongly
> discouraged.*
>
> • The character L specifying that a following e, E, f, g, or G
> conversion corresponds to a long double argument, or a following d, i,
> o, u, x, or X conversion corresponds to a long long argument. Note
> that long long is not specified in ANSI C and therefore not portable
> to all architectures.
Emphasis added. So, pre-C99, L was in fact the recommended modifier for
long long.
Cheers,
Alex.
next prev parent reply other threads:[~2023-06-22 23:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-21 21:37 Rich Felker
2023-06-21 22:10 ` enh
2023-06-22 14:35 ` Markus Wichmann
2023-06-22 14:45 ` Rich Felker
2023-06-22 23:37 ` Alex Xu (Hello71) [this message]
2023-06-22 23:51 ` Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1687470871.bzv5u1iuij.none@localhost \
--to=alex_y_xu@yahoo.ca \
--cc=dalias@libc.org \
--cc=musl@lists.openwall.com \
--cc=nullplan@gmx.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).