Pádraig Brady <[email protected]> writes: > On 26/09/2026 04:35, Collin Funk wrote: >> I pushed this one after testing it on GNU/Linux, macOS, FreeBSD, and >> NetBSD to confirm the memory limit wouldn't cause any trouble. >> Thanks, Pádraig, for finding the version the bug was introduced in. > > we should also probably apply the attached > to document that readlink is impacted also.
Right. I forgot 'readlink' used canonicalize for a few options. I pushed your patch along with the attached patch adding some tests. Collin
>From 6f36b64689796bf89b57eb86265e41dc212968c8 Mon Sep 17 00:00:00 2001 Message-ID: <6f36b64689796bf89b57eb86265e41dc212968c8.1790740867.git.collin.fu...@gmail.com> From: Collin Funk <[email protected]> Date: Tue, 29 Sep 2026 20:39:02 -0700 Subject: [PATCH] tests: readlink: add tests for the symbolic link infinite loop * tests/readlink/rl-1.sh: Add tests for the 'readlink' invocations that would cause an infinite loop before commit b66f3e4e2 (realpath: fix an infinite loop when resolving symbolic links, 2026-09-25). Also test the behavior without an option, which would not cause the infinite loop. --- tests/readlink/rl-1.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/readlink/rl-1.sh b/tests/readlink/rl-1.sh index 4beffad96..7d2a57355 100755 --- a/tests/readlink/rl-1.sh +++ b/tests/readlink/rl-1.sh @@ -55,4 +55,24 @@ test -z "$v" || fail=1 v=$(returns_ 1 readlink missing) || fail=1 test -z "$v" || fail=1 +# From coreutils 9.0 to 9.12, the following would loop until the +# system ran out of memory. +ln -s loop/a loop || framework_failure_ +vm=$(get_min_ulimit_v_ readlink -f link1) && { + echo 'loop/a' >exp || framework_failure_ + for opt in '' -f -e -m; do + if test -z "$opt"; then + exp=exp + exp_rc=0 + else + exp=/dev/null + exp_rc=1 + fi + (ulimit -v $(($vm+6000)) && + returns_ $exp_rc timeout 10 readlink $opt loop >out 2>err) || fail=1 + compare $exp out || fail=1 + compare /dev/null err || fail=1 + done +} + Exit $fail -- 2.55.0
