]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - stdlib/canonicalize.c
realpath: Bring back GNU extension on ENOENT and EACCES [BZ #28996]
[thirdparty/glibc.git] / stdlib / canonicalize.c
index 6237a41d42bbf9596570e7d625bbbb620ada6e1c..e6566bd7d988c45f4b2460f70f45a267eb73bcff 100644 (file)
@@ -400,11 +400,14 @@ realpath_stk (const char *name, char *resolved,
 
 error:
   *dest++ = '\0';
-  if (!failed && resolved != NULL)
+  if (resolved != NULL)
     {
-      if (dest - rname <= get_path_max ())
+      /* Copy the full result on success or partial result if failure was due
+        to the path not existing or not being accessible.  */
+      if ((!failed || errno == ENOENT || errno == EACCES)
+         && dest - rname <= get_path_max ())
        rname = strcpy (resolved, rname);
-      else
+      else if (!failed)
        {
          failed = true;
          __set_errno (ENAMETOOLONG);