https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=f74dc93c6359d7821db4166cf03a3748983d721b

commit f74dc93c6359d7821db4166cf03a3748983d721b
Author:     Chris Denton <[email protected]>
AuthorDate: Mon Mar 10 21:08:13 2025 +0000
Commit:     Corinna Vinschen <[email protected]>
CommitDate: Mon Mar 17 19:58:40 2025 +0100

    fix native symlink spawn passing wrong arg0
    
    Currently when starting a process from bash via a native symlink, argv[0] is
    set to the realpath of the executable and not to the link name. This patch 
fixes
    it so the path of the symlink is seen instead.
    
    The cause is a path conversion in perhaps_suffix which follows native
    symlinks. Hence the fix this patch uses is to add PC_SYM_NOFOLLOW_REP when
    calling path_conv::check to prevent that.
    
    Fixes: be371651146c ("* path.cc (path_conv::check): Don't follow reparse 
point symlinks if PC_SYM_NOFOLLOW_REP flag is set.")
    Signed-off-by: Chris Denton <[email protected]>

Diff:
---
 winsup/cygwin/spawn.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 06b84236d124..ef175e7082f5 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -43,7 +43,9 @@ perhaps_suffix (const char *prog, path_conv& buf, int& err, 
unsigned opt)
 
   err = 0;
   debug_printf ("prog '%s'", prog);
-  buf.check (prog, PC_SYM_FOLLOW | PC_NULLEMPTY | PC_POSIX, stat_suffixes);
+  buf.check (prog,
+            PC_SYM_FOLLOW | PC_SYM_NOFOLLOW_REP | PC_NULLEMPTY | PC_POSIX,
+            stat_suffixes);
 
   if (buf.isdir ())
     {

Reply via email to