]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: pwd: ensure our getcwd fallback is tested master
authorPádraig Brady <P@draigBrady.com>
Tue, 17 Feb 2026 00:18:48 +0000 (00:18 +0000)
committerPádraig Brady <P@draigBrady.com>
Tue, 17 Feb 2026 00:41:50 +0000 (00:41 +0000)
* 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
tests/pwd/pwd-long.sh

diff --git a/NEWS b/NEWS
index 6087494f3df4be18f5174dcc8793e725d4aa473a..179deca90ecc41a308c7b12696824e73c77f02f4 100644 (file)
--- 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.
index 734c2db6cedeff6e407ff712746e363c7e2d6b27..2a010f2f2dacdad462dfaa9e31518e8605fa02f8 100755 (executable)
@@ -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.