[PATCH v3 2/3] realpath: Set errno to ENAMETOOLONG for result larger than PATH_MAX [BZ #28770]
Andreas Schwab
schwab@linux-m68k.org
Mon Jan 24 13:45:38 GMT 2022
On Jan 20 2022, Siddhesh Poyarekar via Libc-alpha wrote:
> diff --git a/stdlib/canonicalize.c b/stdlib/canonicalize.c
> index f36bdf4c76..732dc7ea46 100644
> --- a/stdlib/canonicalize.c
> +++ b/stdlib/canonicalize.c
> @@ -400,8 +400,16 @@ realpath_stk (const char *name, char *resolved,
>
> error:
> *dest++ = '\0';
> - if (resolved != NULL && dest - rname <= get_path_max ())
> - rname = strcpy (resolved, rname);
> + if (resolved != NULL)
> + {
> + if (dest - rname <= get_path_max ())
> + rname = strcpy (resolved, rname);
> + else
> + {
> + failed = true;
> + __set_errno (ENAMETOOLONG);
> + }
> + }
Shouldn't that preserve any preexisting error? I think the result
should only be copied if !failed.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
More information about the Libc-alpha
mailing list