From 34c817f9c51ca22cf643866e3299c58b69074949 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sat, 21 Mar 2020 19:16:17 +0000 Subject: [PATCH 8/8] Extend tests to prove that what remains of xsymlinks() handles symlink loops gracefully. --- Etc/BUGS | 3 --- Src/utils.c | 2 -- Test/B13whence.ztst | 9 +++++++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Etc/BUGS b/Etc/BUGS index 2501d59a7..8112299f5 100644 --- a/Etc/BUGS +++ b/Etc/BUGS @@ -29,6 +29,3 @@ skipped when STTY=... is set for that command 44007 - Martijn - exit in trap executes rest of function See test case in Test/C03traps.ztst. ------------------------------------------------------------------------ -45282: xsymlinks() segfaults on symlink loops -Fixed for some cases; need to audit remaining callers ------------------------------------------------------------------------- diff --git a/Src/utils.c b/Src/utils.c index 25579ba11..634470476 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -913,8 +913,6 @@ slashsplit(char *s) /* expands .. or . expressions and one level of symlinks * * Puts the result in the global "xbuf" - * - * WARNING: This will segfault on symlink loops (thread: workers/45282) */ /**/ diff --git a/Test/B13whence.ztst b/Test/B13whence.ztst index b22363980..ea0a4dae5 100644 --- a/Test/B13whence.ztst +++ b/Test/B13whence.ztst @@ -5,6 +5,9 @@ ln -s real step3 ln -s step3 step2 ln -s step2 step1 + ln -s loop loop + ln -s flip flop + ln -s flop flip touch real chmod +x real prefix=$PWD @@ -20,3 +23,9 @@ 0q:whence symlink resolution >$prefix/step1 -> $prefix/step2 -> $prefix/step3 -> $prefix/real >$prefix/step1 -> $prefix/real + + ( + path=( $PWD/whence.tmp $path ) + whence -S flip || whence -S loop || whence -s flip || whence -s loop + ) +1:whence deals with symlink loops gracefully