mirror of
https://https.git.savannah.gnu.org/git/coreutils.git
synced 2026-01-27 01:44:21 +00:00
mktemp: fix bug with -q and closed stdout
If stdin or stdout is closed, then freopen(,stderr) can violate the premise that STDERR_FILENO==fileno(stderr), which in turn breaks mktemp -q. * bootstrap.conf (gnulib_modules): Add freopen-safer. * src/mktemp.c (includes): Use stdio--.h. * tests/misc/close-stdout: Enhance test to catch bug.
This commit is contained in:
parent
9a8d8f46a5
commit
c768e2231b
@ -92,6 +92,7 @@ gnulib_modules="
|
||||
fopen-safer
|
||||
fprintftime
|
||||
freopen
|
||||
freopen-safer
|
||||
fseeko
|
||||
fsusage
|
||||
fsync
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
/* Written by Jim Meyering and Eric Blake. */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <getopt.h>
|
||||
|
||||
@ -27,6 +26,7 @@
|
||||
#include "error.h"
|
||||
#include "filenamecat.h"
|
||||
#include "quote.h"
|
||||
#include "stdio--.h"
|
||||
#include "tempname.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
|
||||
@ -52,7 +52,8 @@ if "$p/src/test" -w /dev/stdout >/dev/null &&
|
||||
cp --verbose a b >&- 2>/dev/null && fail=1
|
||||
rm -Rf tmpfile-?????? || fail=1
|
||||
mktemp tmpfile-XXXXXX >&- 2>/dev/null && fail=1
|
||||
test -e tmpfile-?????? && fail=1
|
||||
mktemp tmpfile-XXXXXX -q >&- 2>/dev/null && fail=1
|
||||
case `echo tmpfile-??????` in 'tmpfile-??????') ;; *) fail=1 ;; esac
|
||||
fi
|
||||
|
||||
# Likewise for /dev/full, if /dev/full works.
|
||||
@ -61,7 +62,8 @@ if test -w /dev/full && test -c /dev/full; then
|
||||
cp --verbose a b >/dev/full 2>/dev/null && fail=1
|
||||
rm -Rf tmpdir-?????? || fail=1
|
||||
mktemp -d tmpdir-XXXXXX >/dev/full 2>/dev/null && fail=1
|
||||
test -e tmpdir-?????? && fail=1
|
||||
mktemp -d -q tmpdir-XXXXXX >/dev/full 2>/dev/null && fail=1
|
||||
case `echo tmpfile-??????` in 'tmpfile-??????') ;; *) fail=1 ;; esac
|
||||
fi
|
||||
|
||||
Exit $fail
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user