mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-08 17:42:12 +03:00
realpath: Do not copy result on failure (BZ #28815)
On failure, the contents of the resolved buffer passed in by the caller to realpath are undefined. Do not copy any partial resolution to the buffer and also do not test resolved contents in test-canon.c. Resolves: BZ #28815 Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
@@ -400,11 +400,11 @@ realpath_stk (const char *name, char *resolved,
|
||||
|
||||
error:
|
||||
*dest++ = '\0';
|
||||
if (resolved != NULL)
|
||||
if (!failed && resolved != NULL)
|
||||
{
|
||||
if (dest - rname <= get_path_max ())
|
||||
rname = strcpy (resolved, rname);
|
||||
else if (!failed)
|
||||
else
|
||||
{
|
||||
failed = true;
|
||||
__set_errno (ENAMETOOLONG);
|
||||
|
Reference in New Issue
Block a user