- From a50078e7e753be520e2fce37d6f78b7724fbc68e Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 28 Jun 2025 22:51:32 +0200
- Subject: [PATCH] daemon,tests: Fix EASSERT when reading symlink to "/"
- Fix EASSERT when reading symlink to "/", and add a testcase for it.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/symlink.c | 20 +++++++++++++++++++-
- tests/manual_testing.txt | 8 +++++++-
- 2 files changed, 26 insertions(+), 2 deletions(-)
- diff --git a/daemon/symlink.c b/daemon/symlink.c
- index 99ab4fb..8ddd70e 100644
- --- a/daemon/symlink.c
- +++ b/daemon/symlink.c
- @@ -59,7 +59,25 @@ static int abs_path_link(
- }
- /* if link is an absolute path, start path_pos at the beginning */
- else if (is_delimiter(*link)) {
- - path_pos = path->path;
- + if (link_len == 0) {
- + /* This should never happen... */
- + eprintf("abs_path_link(path_pos='%s', link='%.*s', link_len=%d): "
- + "Invalid path, link_len==0\n",
- + path_pos, (int)link_len, link, (int)link_len);
- + status = ERROR_BAD_NETPATH;
- + goto out;
- + }
- + else if (link_len == 1) {
- + /* Special case for $ ln -s '/' mysymlinktoroot # */
- + path_pos = path->path+1;
- + path->path[0] = '\\';
- + path->path[1] = '\0';
- + goto out;
- + }
- + else {
- + /* Normal absolute path... */
- + path_pos = path->path;
- + }
- }
- /* copy each component of link into the path */
- diff --git a/tests/manual_testing.txt b/tests/manual_testing.txt
- index c7e83fd..e491a78 100644
- --- a/tests/manual_testing.txt
- +++ b/tests/manual_testing.txt
- @@ -275,7 +275,13 @@ rm -f symlink1_to_h_tmp ; cmd /C 'mklink /D symlink1_to_h_tmp \\derfwpc5131_ipv4
- #
- # all test should print "OK test <testnum>"
- # ("." is a relative symlink, just included here for more coverage)
- -ksh93 -c 'typeset -a a=( "/" "/usr" "/tmp" "/usr/bin" "$PWD" "/dev/null" "." ) ; for ((i=0 ; i < ${#a[@]} ; i++ )) ; do rm -f "syml$i" ; ln -sf "${a[$i]}" "syml$i" ; l="$(readlink "syml$i")" ; if [[ "$l" == "${a[$i]}" ]] ; then printf "OK test %d\n" i ; else printf "FAIL test %d\n" i ; fi ; done'
- +ksh93 -c 'typeset -a a=( "/" "/usr" "/usr/" "/tmp" "/usr/bin" "$PWD" "/dev/null" "." ) ; for ((i=0 ; i < ${#a[@]} ; i++ )) ; do rm -f "syml$i" ; ln -sf "${a[$i]}" "syml$i" ; l="$(readlink "syml$i")" ; if [[ "$l" == "${a[$i]}" ]] ; then printf "OK test %d\n" i ; else printf "FAIL test %d\n" i ; fi ; done'
- +
- +#
- +# Test whether cmd.exe can follow symlink to "/" (root), which should point to C:cygwin64\ or C:\cygwin\
- +# (CYGWIN='winsymlinks:nativestrict' is used so the same test works with NTFS too)
- +#
- +CYGWIN='winsymlinks:nativestrict' bash -c 'rm -f symlrootdotslash && ln -sf / symlrootdotslash && cmd /C "cd symlrootdotslash" && echo "Test OK"'
- #
- # Test for mkdir with UNC path
- --
- 2.45.1
msnfs41client: Fix assert when reading a symlink to "/" from cmd.exe, 2025-06-28
Posted by Anonymous on Sat 28th Jun 2025 21:57
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.
rovema.kpaste.net RSS