summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2022-07-03 18:09:56 -0500
committerPaul Eggert <eggert@cs.ucla.edu>2022-07-03 18:17:41 -0500
commit40dba285721e4a83482615e40c1d7521275ccab7 (patch)
treea3b395a9f798da75de6af6e83601a27e94c1f597 /testsuite
parentbfdc4d6ee4811c34d8756fcca7895f5d2eed6946 (diff)
downloadsed-40dba285721e4a83482615e40c1d7521275ccab7.tar.gz
sed: fix infloop with symlink cycles
* bootstrap.conf (gnulib_modules): Add eloop-threshold, idx, minmax, readlink. * configure.ac: Do not check for lstat; no longer needed. (ENABLE_FOLLOW_SYMLINKS): Remove; all uses removed. (TEST_SYMLINKS): Depend only on readlink. * sed/utils.c: Include eloop-threshold.h, idx.h, minmax.h. (SSIZE_IDX_MAX): New macro. (follow_symlink): Rewrite to not loop when given a symlink cycle. Do not use lstat, since readlink suffices. Use just one memory buffer, not two; this simplifies memory management. * testsuite/follow-symlinks.sh: Adjust diagnostics to to match revised behavior. Test for symlink loops.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/follow-symlinks.sh8
1 files changed, 6 insertions, 2 deletions
diff --git a/testsuite/follow-symlinks.sh b/testsuite/follow-symlinks.sh
index 9066876..880a80e 100644
--- a/testsuite/follow-symlinks.sh
+++ b/testsuite/follow-symlinks.sh
@@ -52,9 +52,9 @@ sed --follow-symlinks -n 'F' la1 la2 > out-two-symlinks || fail=1
compare_ exp-two-symlinks out-two-symlinks || fail=1
# non-existing input with --follow-symlink
-# implementation note: lstat() will be called before open(), thus 'cannot stat'.
+# implementation note: readlink called before open, thus "couldn't readlink"
cat <<\EOF >exp-stat || framework_failure_
-sed: cannot stat badfile:
+sed: couldn't readlink badfile:
EOF
returns_ 4 sed --follow-symlinks 'F' badfile >/dev/null 2>err-stat || fail=1
@@ -69,4 +69,8 @@ echo "$PWD/a" > exp-la-abs || framework_failure_
sed -n --follow-symlinks 'F' la-abs > out-la-abs || fail=1
compare_ exp-la-abs out-la-abs || fail=1
+# symlink loop
+ln -s la-loop la-loop || framework_failure_
+sed --follow-symlinks -i s/a/b/ la-loop && fail=1
+
Exit $fail