pastebin - collaborative debugging tool
rovema.kpaste.net RSS


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

  1. From a50078e7e753be520e2fce37d6f78b7724fbc68e Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Sat, 28 Jun 2025 22:51:32 +0200
  4. Subject: [PATCH] daemon,tests: Fix EASSERT when reading symlink to "/"
  5.  
  6. Fix EASSERT when reading symlink to "/", and add a testcase for it.
  7.  
  8. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  9. ---
  10. daemon/symlink.c         | 20 +++++++++++++++++++-
  11.  tests/manual_testing.txt |  8 +++++++-
  12.  2 files changed, 26 insertions(+), 2 deletions(-)
  13.  
  14. diff --git a/daemon/symlink.c b/daemon/symlink.c
  15. index 99ab4fb..8ddd70e 100644
  16. --- a/daemon/symlink.c
  17. +++ b/daemon/symlink.c
  18. @@ -59,7 +59,25 @@ static int abs_path_link(
  19.      }
  20.      /* if link is an absolute path, start path_pos at the beginning */
  21.      else if (is_delimiter(*link)) {
  22. -        path_pos = path->path;
  23. +        if (link_len == 0) {
  24. +            /* This should never happen... */
  25. +            eprintf("abs_path_link(path_pos='%s', link='%.*s', link_len=%d): "
  26. +                "Invalid path, link_len==0\n",
  27. +                path_pos, (int)link_len, link, (int)link_len);
  28. +            status = ERROR_BAD_NETPATH;
  29. +            goto out;
  30. +        }
  31. +        else if (link_len == 1) {
  32. +            /* Special case for $ ln -s '/' mysymlinktoroot # */
  33. +            path_pos = path->path+1;
  34. +            path->path[0] = '\\';
  35. +            path->path[1] = '\0';
  36. +            goto out;
  37. +        }
  38. +        else {
  39. +            /* Normal absolute path... */
  40. +            path_pos = path->path;
  41. +        }
  42.      }
  43.  
  44.      /* copy each component of link into the path */
  45. diff --git a/tests/manual_testing.txt b/tests/manual_testing.txt
  46. index c7e83fd..e491a78 100644
  47. --- a/tests/manual_testing.txt
  48. +++ b/tests/manual_testing.txt
  49. @@ -275,7 +275,13 @@ rm -f symlink1_to_h_tmp ; cmd /C 'mklink /D symlink1_to_h_tmp \\derfwpc5131_ipv4
  50.  #
  51.  # all test should print "OK test <testnum>"
  52.  # ("." is a relative symlink, just included here for more coverage)
  53. -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'
  54. +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'
  55. +
  56. +#
  57. +# Test whether cmd.exe can follow symlink to "/" (root), which should point to C:cygwin64\ or C:\cygwin\
  58. +# (CYGWIN='winsymlinks:nativestrict' is used so the same test works with NTFS too)
  59. +#
  60. +CYGWIN='winsymlinks:nativestrict' bash -c 'rm -f symlrootdotslash &&  ln -sf / symlrootdotslash && cmd /C "cd symlrootdotslash" && echo "Test OK"'
  61.  
  62.  #
  63.  # Test for mkdir with UNC path
  64. --
  65. 2.45.1

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at