From: Quentin Rameau <quinq@fifth.space>
To: musl@lists.openwall.com
Subject: Re: [musl] request: please detect reads from stdin with unflushed writes to stdout
Date: Mon, 25 Oct 2021 14:44:31 +0200 [thread overview]
Message-ID: <20211025144431.00718c87@tpx.quinq.eu.org> (raw)
In-Reply-To: <CAAMnvkfEPVNDCOKL8aStaSLcYyPPaVtWt8O8CXUwRHjLt9uPBA@mail.gmail.com>
> Hello,
Hi Lorenzo,
> there are a few programs around that do something like
> printf("question: ");
> fgets(ans, sizeof ans, stdin);
>
> without fflushing stdout and get away with it because it happens to work
> under glibc.
> (fyi the ones I stumbled onto are mkfs.xfs and, vipw/vigr from util-linux,
> then the developer noticed the same with chfn/chsh)
>
> Ideally that would be taken care of by either some compiler warning (but
> not even clang's -Weverything catches that) or by some static analysis
> tool, but I couldn't find any.
>
> ... with do_something() being either flushing stdout or printing some kind
> of warning to stderr (isatty?) or to syslog.
> Any suggestion, corrections etc are obviously very welcome.
Suggestion: fix those broken programs!
If one wants to make sure what you print is flushed at a certain point,
ones have to flush the stream.
prev parent reply other threads:[~2021-10-25 12:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-25 12:28 Lorenzo Beretta
2021-10-25 12:44 ` Quentin Rameau [this message]
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=20211025144431.00718c87@tpx.quinq.eu.org \
--to=quinq@fifth.space \
--cc=musl@lists.openwall.com \
/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).