mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-21 01:12:26 +08:00
realpath: Bring back GNU extension on ENOENT and EACCES [BZ #28996]
The GNU extension for realpath states that if the path resolution fails
with ENOENT or EACCES and the resolved buffer is non-NULL, it will
contain part of the path that failed resolution.
commit 949ad78a18
broke this when it
omitted the copy on failure. Bring it back partially to continue
supporting this GNU extension.
Resolves: BZ #28996
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Andreas Schwab <schwab@linux-m68k.org>
This commit is contained in:
parent
7f2ddf7400
commit
b416555431
@ -400,11 +400,14 @@ realpath_stk (const char *name, char *resolved,
|
||||
|
||||
error:
|
||||
*dest++ = '\0';
|
||||
if (!failed && resolved != NULL)
|
||||
if (resolved != NULL)
|
||||
{
|
||||
if (dest - rname <= get_path_max ())
|
||||
/* Copy the full result on success or partial result if failure was due
|
||||
to the path not existing or not being accessible. */
|
||||
if ((!failed || errno == ENOENT || errno == EACCES)
|
||||
&& dest - rname <= get_path_max ())
|
||||
rname = strcpy (resolved, rname);
|
||||
else
|
||||
else if (!failed)
|
||||
{
|
||||
failed = true;
|
||||
__set_errno (ENAMETOOLONG);
|
||||
|
@ -174,8 +174,8 @@ do_test (int argc, char ** argv)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Only on success verify that buf contains the result too. */
|
||||
if (result != NULL
|
||||
/* Verify buf contents if the call succeeded or failed with ENOENT. */
|
||||
if ((result != NULL || errno == ENOENT)
|
||||
&& !check_path (buf, tests[i].out ? tests[i].out : tests[i].resolved))
|
||||
{
|
||||
printf ("%s: flunked test %d (expected resolved `%s', got `%s')\n",
|
||||
|
Loading…
Reference in New Issue
Block a user