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>
(cherry picked from commit
949ad78a189194048df8a253bb31d1d11d919044)
[25812] Libio vtable protection is sometimes only partially enforced
[27576] gmon: improve mcount overflow handling
[27821] ungetc: Fix backup buffer leak on program exit
+ [28815] realpath should not copy to resolved buffer on error
[28838] FAIL: elf/tst-p_align3
[28846] CMSG_NXTHDR may trigger -Wstrict-overflow warning
[28850] linux: __get_nprocs_sched reads uninitialized memory from the stack
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);
continue;
}
- if (!check_path (buf, tests[i].out ? tests[i].out : tests[i].resolved))
+ /* Only on success verify that buf contains the result too. */
+ if (result != NULL
+ && !check_path (buf, tests[i].out ? tests[i].out : tests[i].resolved))
{
printf ("%s: flunked test %d (expected resolved `%s', got `%s')\n",
argv[0], i, tests[i].out ? tests[i].out : tests[i].resolved,