From c6e0b0b5b0b7922cdf0dce2af671e0c7e500df95 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Tue, 29 Dec 2020 11:37:34 -0300 Subject: stdlib: Sync canonicalize with gnulib [BZ #10635] [BZ #26592] [BZ #26341] [BZ #24970] It sync with gnulib version ae9fb3d66. The testcase for BZ#23741 (stdlib/test-bz22786.c) is adjusted to check also for ENOMEM. The patch fixes multiple realpath issues: - Portability fixes for errno clobbering on free (BZ#10635). The function does not call free directly anymore, although it might be done through scratch_buffer_free. The free errno clobbering is being tracked by BZ#17924. - Pointer arithmetic overflows in realpath (BZ#26592). - Realpath cyclically call __alloca(path_max) to consume too much stack space (BZ#26341). - Realpath mishandles EOVERFLOW; stat not needed anyway (BZ#24970). The check is done through faccessat now. Checked on x86_64-linux-gnu and i686-linux-gnu. --- stdlib/test-bz22786.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'stdlib/test-bz22786.c') diff --git a/stdlib/test-bz22786.c b/stdlib/test-bz22786.c index 84d3ff8cfb..df454949c4 100644 --- a/stdlib/test-bz22786.c +++ b/stdlib/test-bz22786.c @@ -62,12 +62,10 @@ do_test (void) /* This call crashes before the fix for bz22786 on 32-bit platforms. */ p = realpath (path, NULL); - - if (p != NULL || errno != ENAMETOOLONG) - { - printf ("realpath: %s (%m)", p); - return EXIT_FAILURE; - } + TEST_VERIFY (p == NULL); + /* For 64-bit platforms readlink return ENAMETOOLONG, while for 32-bit + realpath will try to allocate a buffer larger than PTRDIFF_MAX. */ + TEST_VERIFY (errno == ENOMEM || errno == ENAMETOOLONG); /* Cleanup. */ unlink (lnk); @@ -78,5 +76,4 @@ do_test (void) return 0; } -#define TEST_FUNCTION do_test #include -- cgit v1.2.3