1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-07-25 10:16:53 +02:00

sort,split,yes: ensure pipe and pipe2 don't open standard descriptors

* bootstrap.conf (gnulib_modules): Add pipe2-safer.
* cfg.mk (sc_require_unistd_safer): New rule for 'make syntax-check'.
* gl/lib/fd-reopen.c: Include unistd--.h instead of unistd.h.
* src/sort.c: Include unistd--.h.
* src/split.c: Likewise.
* src/yes.c: Likewise.
This commit is contained in:
Collin Funk
2026-03-17 23:06:16 -07:00
parent 58d88d2435
commit f421d01128
6 changed files with 18 additions and 1 deletions
+1
View File
@@ -213,6 +213,7 @@ gnulib_modules="
physmem
pipe-posix
pipe2
pipe2-safer
posix-shell
posix_spawn
posix_spawn_file_actions_addclose
+13
View File
@@ -603,6 +603,19 @@ sc_require_stdlib_safer:
else :; \
fi
# Ensure that "unistd--.h" is used where appropriate.
sc_require_unistd_safer:
@if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
files=$$(grep -El '$(begword)(pipe2?|dup[23]?) ?\(' \
$$($(VC_LIST_EXCEPT) \
| grep '\.[ch]$$')); \
test -n "$$files" && grep -LE 'include "unistd--.h"' $$files \
| grep . && \
{ echo '$(ME): the above files should use "unistd--.h"' \
1>&2; exit 1; } || :; \
else :; \
fi
sc_prohibit_perl_hash_quotes:
@prohibit="\{'[A-Z_]+' *[=}]" \
halt="in Perl code, write \$$hash{KEY}, not \$$hash{'K''EY'}" \
+1 -1
View File
@@ -23,7 +23,7 @@
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include "unistd--.h"
/* Open a file to a particular file descriptor. This is like standard
'open', except it always returns DESIRED_FD if successful. */
+1
View File
@@ -51,6 +51,7 @@
#include "stdlib--.h"
#include "strnumcmp.h"
#include "term-sig.h"
#include "unistd--.h"
#include "xmemcoll.h"
#include "xnanosleep.h"
#include "xstrtol.h"
+1
View File
@@ -40,6 +40,7 @@
#include "sig2str.h"
#include "sys-limits.h"
#include "temp-stream.h"
#include "unistd--.h"
#include "xbinary-io.h"
#include "xdectoint.h"
#include "xstrtol.h"
+1
View File
@@ -27,6 +27,7 @@
#include "full-write.h"
#include "isapipe.h"
#include "long-options.h"
#include "unistd--.h"
/* The official name of this program (e.g., no 'g' prefix). */
#define PROGRAM_NAME "yes"