From 8a0d9b889f3db7912234b84a86e6ce68ee8e1da2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?=
Date: Tue, 17 Feb 2026 00:18:48 +0000 Subject: [PATCH] tests: pwd: ensure our getcwd fallback is tested * tests/pwd/pwd-long.sh: Avoid the getcwd syscall, to ensure our fallback getcwd code is exercised. * NEWS: Mention the recent bug fix in pwd. --- NEWS | 4 ++++ tests/pwd/pwd-long.sh | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 6087494f3d..179deca90e 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,10 @@ GNU coreutils NEWS -*- outline -*- 'kill --help' now has links to valid anchors in the html manual. [bug introduced in coreutils-9.10] + 'pwd' on ancient systems will no longer overflow a buffer + when operating in deep paths longer than twice the system PATH_MAX. + [bug introduced in coreutils-9.6] + ** New Features 'date --date' now parses dot delimited dd.mm.yy format common in Europe. diff --git a/tests/pwd/pwd-long.sh b/tests/pwd/pwd-long.sh index 734c2db6ce..2a010f2f2d 100755 --- a/tests/pwd/pwd-long.sh +++ b/tests/pwd/pwd-long.sh @@ -19,6 +19,7 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ pwd +uses_strace_ require_readable_root_ require_perl_ @@ -26,9 +27,18 @@ require_perl_ ARGV_0=$0 export ARGV_0 +# Disable the getcwd syscall if possible, so more of our code is exercised. +if strace -f -o /dev/null -e 'getcwd' -e fault=all:error=ENOSYS true; then + no_sys_getcwd() { + strace -f -o /dev/null -e 'getcwd' -e fault=all:error=ENOSYS "$@" + } +else + no_sys_getcwd() { "$@"; } +fi + # Don't use CuTmpdir here, since File::Temp's use of rmtree can't # remove the deep tree we create. -$PERL -Tw -I"$abs_srcdir/tests" -MCuSkip -- - <<\EOF +no_sys_getcwd $PERL -Tw -I"$abs_srcdir/tests" -MCuSkip -- - <<\EOF # Show that pwd works even when the length of the resulting # directory name is longer than PATH_MAX. -- 2.47.3