bug#9762: tac fails when given multiple non-seekable inputs due to misus
From:
Ambrose Feinstein
Subject:
bug#9762: tac fails when given multiple non-seekable inputs due to misuse of mkstemp()
Date:
Sat, 15 Oct 2011 13:40:17 -0700
Trivial reproduction:
$ true | tac - -
tac: cannot create temporary file in `/tmp': Invalid argument
This is present in coreutils 8.14.
The cause is the way "template" is reused in copy_to_temp(). The
"XXXXXX" suffix is clobbered by the first call to mkstemp(), so the
next call returns EINVAL.
It looks like the intent is to call mkstemp() at most once and then
reuse that file; for example, record_or_unlink_tempfile() will delete
at most one file on exit.