From 0093ac8d57a0f1a16fd09d98f6a524dddb6053e7 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 13 Mar 2014 17:05:04 -0700 Subject: ln: with -sr, don't segfault for a TARGET of '' Prior to this change, "ln -sr '' F" would segfault, attempting to read path2[1] in relpath.c's path_common_prefix function. This problem arises whenever canonicalize_filename_mode returns NULL. * src/ln.c (convert_abs_rel): Call relpath only when both canonicalize_filename_mode calls return non-NULL. * tests/ln/relative.sh: Add a test to trigger this failure. * THANKS.in: List reporter's name/address. * NEWS (Bug fixes): Mention it. Reported by Erik Bernstein in 739752@bugs.debian.org. Fixes http://bugs.gnu.org/17010. --- tests/ln/relative.sh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/ln/relative.sh') diff --git a/tests/ln/relative.sh b/tests/ln/relative.sh index 7636695ce..5cf280a58 100755 --- a/tests/ln/relative.sh +++ b/tests/ln/relative.sh @@ -45,4 +45,9 @@ mkdir web ln -sr latest web/latest test $(readlink web/latest) = '../release2' || fail=1 +# Expect this to fail with exit status 1, or to succeed quietly (freebsd). +# Prior to coreutils-8.23, it would segfault. +ln -sr '' F +case $? in [01]) ;; *) fail=1;; esac + Exit $fail -- cgit v1.2.3-54-g00ecf