about summary refs log tree commit diff
path: root/stdlib/canonicalize.c
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@sourceware.org>2022-01-24 21:36:41 +0530
committerSiddhesh Poyarekar <siddhesh@sourceware.org>2022-01-24 21:40:00 +0530
commit84d2d0fe20bdf94feed82b21b4d7d136db471f03 (patch)
treead576db6ecba25b33e7ed4a103eef90ef94d448a /stdlib/canonicalize.c
parentd8d94863ef125a392b929732b37e07dc927fbcd1 (diff)
downloadglibc-84d2d0fe20bdf94feed82b21b4d7d136db471f03.tar.gz
glibc-84d2d0fe20bdf94feed82b21b4d7d136db471f03.tar.xz
glibc-84d2d0fe20bdf94feed82b21b4d7d136db471f03.zip
realpath: Avoid overwriting preexisting error (CVE-2021-3998)
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>
Diffstat (limited to 'stdlib/canonicalize.c')
-rw-r--r--stdlib/canonicalize.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/stdlib/canonicalize.c b/stdlib/canonicalize.c
index 732dc7ea46..6caed9e70e 100644
--- a/stdlib/canonicalize.c
+++ b/stdlib/canonicalize.c
@@ -404,7 +404,7 @@ error:
     {
       if (dest - rname <= get_path_max ())
 	rname = strcpy (resolved, rname);
-      else
+      else if (!failed)
 	{
 	  failed = true;
 	  __set_errno (ENAMETOOLONG);