]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
realpath: Avoid overwriting preexisting error (CVE-2021-3998)
authorSiddhesh Poyarekar <siddhesh@sourceware.org>
Mon, 24 Jan 2022 16:06:41 +0000 (21:36 +0530)
committerSiddhesh Poyarekar <siddhesh@sourceware.org>
Mon, 24 Jan 2022 16:10:00 +0000 (21:40 +0530)
Set errno and failure for paths that are too long only if no other error
occurred earlier.

Related: BZ #28770

Reviewed-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
stdlib/canonicalize.c

index 732dc7ea46c8af4f33e779cb8be951c1e3aac2e6..6caed9e70e14827f4320a6894a132ad4095a1065 100644 (file)
@@ -404,7 +404,7 @@ error:
     {
       if (dest - rname <= get_path_max ())
        rname = strcpy (resolved, rname);
-      else
+      else if (!failed)
        {
          failed = true;
          __set_errno (ENAMETOOLONG);