GNU bug report logs - #9762
tac fails when given multiple non-seekable inputs due to misuse of mkstemp()

Previous Next

Package: coreutils;

Reported by: Ambrose Feinstein <ambrose <at> google.com>

Date: Sat, 15 Oct 2011 20:58:01 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ambrose Feinstein <ambrose <at> google.com>
To: bug-coreutils <at> gnu.org
Subject: 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.




This bug report was last modified 13 years and 223 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.