diff mbox series

[committed] realpath: Avoid overwriting preexisting error (CVE-2021-3998)

Message ID 20220124160825.3777358-1-siddhesh@sourceware.org
State Committed
Headers show
Series [committed] realpath: Avoid overwriting preexisting error (CVE-2021-3998) | expand

Commit Message

Siddhesh Poyarekar Jan. 24, 2022, 4:08 p.m. UTC
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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

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);